I just decided to kick the fflib QueryFactory out of a customer project because of its complexity and sub-par performance.

My Custom Query Building is fast but I fear I will reinvent the wheel.

Which other "lean" (compared to fflib) Query Builder Libs are out there? Which one do you use and why?

Features I would like are:

  • Way to centralized fields to query (class, FieldSet, etc)
  • Support of Subqueries using same mechanisms
  • Leveraging new native Security features
  • Fluent API style
  • Extendable
  • Support of ORDER BY, LIMIT, COUNT etc.
  • 2
    Can you revise your question to specify what features you're looking for? Some people want a 'WHERE clause builder', some need support for field sets, some need CRUD/FLS enforcement, and some need none of that. There are a bunch of abandoned projects (like apex-commons.github.io/query/soql-builder) that do all or some of those things
    – daveespo
    Jun 13 at 12:28
  • 1
    as an fflib user myself, I can sympathize with the CPU cost in constructing SELECT field lists and, to a lesser extent, WHERE clauses. When faced with specific selectors that perform poorly, I've recoded them as either inline SOQL or used fieldsets rather than getFields(). Have you posted this as an issue on the apex-common github repo
    – cropredy
    Jun 14 at 7:21

1 Answer 1


It might be useful for you to include what features you're looking for in a query builder in your question. Because it's not obvious to me what you would need, like, dislike in a query builder. e.g. should it support mocking the database?

There is a query builder one in Nebula Core:


Unsurprisingly (since I wrote it), I quite like it. My team and I have used it extensively. It does use some of the other Nebula Core classes, but not in a particularly deep way. So it would take a little modification to run standalone.

The one aspect we struggled with is that it has the option to add all fields e.g. in case you plan to clone the records you're querying. That seems to be subject to a platform bug where the describe calls across namespaces return fields that don't actually exist in the org.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.