Re: explain analyze faster then query

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Mariel Cherkassky <mariel(dot)cherkassky(at)gmail(dot)com>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: explain analyze faster then query
Date: 2018-11-25 14:12:25
Message-ID: 20181125141225.GQ10913@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-performance

On Sun, Nov 25, 2018 at 03:37:46PM +0200, Mariel Cherkassky wrote:
> I run it from inside the machine on the local database.
> For example :
>
> db=# create table rule_test as select generate_series(1,100000000);
> SELECT 100000000

> db=# explain analyze select generate_series from rule_test order by
> generate_series asc;

So it's returning 100M rows to the client, which nominally will require moving
400MB.

And pgsql is formatting the output.

I did a test with 10M rows:

[pryzbyj(at)database ~]$ command time -v psql postgres -c 'SELECT * FROM rule_test' |wc -c&
Command being timed: "psql postgres -c SELECT * FROM rule_test"
User time (seconds): 11.52
Percent of CPU this job got: 78%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:17.25
Maximum resident set size (kbytes): 396244
...
170000053

Explain analyze takes 0.8sec, but returning query results uses 11sec CPU time
on the *client*, needed 400MB RAM (ints now being represented as strings
instead of machine types), and wrote 170MB to stdout, Also, if the output is
being piped to less, the data is going to be buffered there, which means your
query is perhaps using 4GB RAM in psql + 4GB in less..

Is the server swapping ? check "si" and "so" in output of "vmstat -w 1"

Justin

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Khushboo Vashi 2018-11-26 04:41:39 Re: could not connect to server, in order to operate pgAdmin/PostgreSQL
Previous Message Mariel Cherkassky 2018-11-25 13:37:46 Re: explain analyze faster then query

Browse pgsql-performance by date

  From Date Subject
Next Message Viswanath 2018-11-26 10:11:18 Optimizer choosing the wrong plan
Previous Message Mariel Cherkassky 2018-11-25 13:37:46 Re: explain analyze faster then query