0

I want to execute a SQL query without displaying results. It might cause a faster query. Is it possible?

select id
from trips
order by l_pickup <->
(select l_pickup
from trips
where id =605689)
limit 100000

This query takes approximately 40 seconds.

1 Answer 1

3

explain (analyze) will execute the statement but will not return the results (only the execution plan).

Quote from the manual:

With this option, EXPLAIN actually executes the query, and then displays the true row counts and true run time

So you can use:

explain (analyze)
select id
from trips
order by l_pickup <-> (select l_pickup
                       from trips
                       where id =605689)
limit 100000;

The runtime reported by that is the time on the server without sending the data to the client. It will also show you what the slowest part of the statement is.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.