Page 1 of 1

Help with LIMIT performance?

Posted: Wed Aug 05, 2015 6:16 pm
by usli06
Hi,

Is there a any way to enhance the performance of queries using the LIMIT option? It seems like if I am querying large tables, even adding a LIMIT 1 still takes a long time...

Thanks guys!

Re: Help with LIMIT performance?

Posted: Wed Aug 05, 2015 8:41 pm
by NorbertKrupa
What does your query look like?

Also take a look at Optimizing LIMIT Queries with ROW_NUMBER Predicates.

Re: Help with LIMIT performance?

Posted: Wed Aug 05, 2015 8:51 pm
by scutter
It’s going to depend greatly on what sort of query you are executing. Each node will limit the data that it sends back to the initiator to a single row as quickly as it can. But if the query needs to do lots of work before it can apply the LIMIT 1 then you need to wait. For example a large GROUP BY HASH that is executing prior to the LIMIT 1 will need to finish executing before the LIMIT 1 can be applied.

How long is the “long time” in your case?

—Sharon