Selecting nodes by content type and value of a custom field I need to select nodes (1) of a certain content type and (2) satisfying a test against a custom field's value. Pseudo-code would be: 

select all nodes of type TYPE_X which are published and where MY_FIELD = 'x'


I tried that with the EntityFieldQuery suggested here: How do I query a content type with custom fields in the &#39;condition&#39; statement
but Drupal/php crashes with "Fatal error: Allowed memory size of x bytes exhausted..."

So - what would be the correct code to use? I would appreciate a query which takes revisions into account.
In Views, you could do this:


Create a view, filter on node TYPE and node PUBLISHED
Create an argument/contextual filter using your CUSTOM FIELD
In Fields, select NID (and/or TITLE or whatever you want to work with in the node(s))


Preview the view, putting FILTERONTHIS in the arguments/contextual filter area.

Look at the SQL it generated in the Preview and cut/paste it into whatever you need, substituting FILTERONTHIS for a variable of your chosing. Or, save the view and then use views_get_view_result() to access the result.