For a fixed countably infinite structure Gamma with finite relational signature tau, we study the following computational problem: input are quantifier-free tau-formulas phi(0), phi(1), phi(n) that define relations R-0, R-1,...,R-n,, over Gamma. The question is whether the relation R-0 is primitive positive definable from R-1,,, R-n, i.e., definable by a first-order formula that uses only relation symbols for R-1,..., R-n, equality, conjunctions, and existential quantification (disjunction, negation, and universal quantification are forbidden). We show decidability of this problem for all structures Gamma that have a first-order definition in an ordered homogeneous structure Delta with a finite relational signature whose age is a Ramsey class and determined by finitely many forbidden substructures. Examples of structures Gamma with this property are the order of the rationale, the random graph, the homogeneous universal poset, the random tournament, all homogeneous universal C-relations, and many more. We also obtain decidability of the problem when we replace primitive positive definability by existential positive, or existential definability, Our proof makes use of universal algebraic and model theoretic concepts. Ramsey theory, and a recent characterization of Ramsey classes in topological dynamics.