0

What factors affect the speed of a find() query?

As my database becomes larger and larger, especially querying elements like EventLogEntry, I'm trying to figure out how to increase the speed of my python scripts.

What affects the speed of specifically the find() query?  If I do a find() on a single id, is that quicker than a find which has to satisfy multiple filters?  If it has to satisfy multiple filters, does it matter what order they are presented?  Are certain fields faster to query than others?

Are queries of fields that return integers and text faster than multi-entity fields?  Are queries faster if they return fewer fields?

If I am looking for Event Log Entries from a particular user and within a particular id-range, is it faster to get the id-range first and then filter based on the user?

Is find_one() faster than find()?  Is finding an element faster than finding nothing?  Vice versa?

So many questions...

1 comment

  • 0
    Avatar
    Isaac Reuben

    Eli, let me see if I can answer those!  A find on a single id will be faster than any other query, and should be the same speed no matter how many records exist.  The order of the filters doesn't matter.  Id and entity fields would likely be the fastest to search on, and text fields (using "contains" as the filter type) would be the slowest.

    Single value fields are faster to return than multi-value fields, and the fewer fields you ask for the faster it will return (if for no other reason than network speed).

    If you send filters to the server for both a range of event ids and for events by a user, the db should optimize that to return it in the fastest way.

    find_one() and find() are the same speed if doing the same search.  Returning nothing is slightly faster just because don't have to send any rows back (but still had to search all the rows to find that out).

    If you have any example queries that are going slow, you can post them here (or send to support) and I can see if there is something we can do to speed them up.

    Cheers,

    - Isaac

Please sign in to leave a comment.