Обсуждение: [GENERAL] PSQL command line print speed

Поиск
Список
Период
Сортировка

[GENERAL] PSQL command line print speed

От
Adrian Myers
Дата:
Is there a way to speed up the actual line-by-line display of the psql console in version 8.4?

Queries which perform in a few milliseconds through a driver (psycopg2 in this case) can take several seconds or minutes to complete in the console, seemingly just due to it printing lines at a very leisurely pace (in other words, this is not the delay caused by the query itself, often it starts printing almost instantly but spends a very long time just writing output). While overall application performance is unaffected, simple admin tasks and poking around the data take longer than I would like as a result. Is there any way to improve just the display/write performance in the console?

Thanks for any insight,
Adrian

Re: [GENERAL] PSQL command line print speed

От
Pavel Stehule
Дата:
Hi

2017-05-17 18:03 GMT+02:00 Adrian Myers <hadrianmyers@gmail.com>:
Is there a way to speed up the actual line-by-line display of the psql console in version 8.4?

Queries which perform in a few milliseconds through a driver (psycopg2 in this case) can take several seconds or minutes to complete in the console, seemingly just due to it printing lines at a very leisurely pace (in other words, this is not the delay caused by the query itself, often it starts printing almost instantly but spends a very long time just writing output). While overall application performance is unaffected, simple admin tasks and poking around the data take longer than I would like as a result. Is there any way to improve just the display/write performance in the console?

try to play with used format

probably unalign format will be faster

postgres=# \pset format unaligned 
Output format is unaligned.

Regards

Pavel
 

Thanks for any insight,
Adrian

Re: [GENERAL] PSQL command line print speed

От
Adrian Klaver
Дата:
On 05/17/2017 09:03 AM, Adrian Myers wrote:
> Is there a way to speed up the actual line-by-line display of the psql
> console in version 8.4?
>
> Queries which perform in a few milliseconds through a driver (psycopg2
> in this case) can take several seconds or minutes to complete in the
> console, seemingly just due to it printing lines at a very leisurely
> pace (in other words, this is not the delay caused by the query itself,
> often it starts printing almost instantly but spends a very long time
> just writing output). While overall application performance is
> unaffected, simple admin tasks and poking around the data take longer
> than I would like as a result. Is there any way to improve just the
> display/write performance in the console?

Is this a psql client local to the server machine or across a network?

>
> Thanks for any insight,
> Adrian


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: [GENERAL] PSQL command line print speed

От
Adrian Klaver
Дата:
On 05/17/2017 09:22 AM, Adrian Myers wrote:

Please reply to list also
Ccing list

> Hi Adrian, it is running locally.

In addition to Pavel's suggestions:

In psql what does \pset show for the pager setting?



>
> On Wed, May 17, 2017 at 12:21 PM, Adrian Klaver
> <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> wrote:
>
>     On 05/17/2017 09:03 AM, Adrian Myers wrote:
>
>         Is there a way to speed up the actual line-by-line display of
>         the psql console in version 8.4?
>
>         Queries which perform in a few milliseconds through a driver
>         (psycopg2 in this case) can take several seconds or minutes to
>         complete in the console, seemingly just due to it printing lines
>         at a very leisurely pace (in other words, this is not the delay
>         caused by the query itself, often it starts printing almost
>         instantly but spends a very long time just writing output).
>         While overall application performance is unaffected, simple
>         admin tasks and poking around the data take longer than I would
>         like as a result. Is there any way to improve just the
>         display/write performance in the console?
>
>
>     Is this a psql client local to the server machine or across a network?
>
>
>
>         Thanks for any insight,
>         Adrian
>
>
>
>     --
>     Adrian Klaver
>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: [GENERAL] PSQL command line print speed

От
Adrian Myers
Дата:
Ah I should have mentioned, the pager is off.

On Wed, May 17, 2017 at 12:34 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 05/17/2017 09:22 AM, Adrian Myers wrote:

Please reply to list also
Ccing list

Hi Adrian, it is running locally.

In addition to Pavel's suggestions:

In psql what does \pset show for the pager setting?




On Wed, May 17, 2017 at 12:21 PM, Adrian Klaver <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> wrote:

    On 05/17/2017 09:03 AM, Adrian Myers wrote:

        Is there a way to speed up the actual line-by-line display of
        the psql console in version 8.4?

        Queries which perform in a few milliseconds through a driver
        (psycopg2 in this case) can take several seconds or minutes to
        complete in the console, seemingly just due to it printing lines
        at a very leisurely pace (in other words, this is not the delay
        caused by the query itself, often it starts printing almost
        instantly but spends a very long time just writing output).
        While overall application performance is unaffected, simple
        admin tasks and poking around the data take longer than I would
        like as a result. Is there any way to improve just the
        display/write performance in the console?


    Is this a psql client local to the server machine or across a network?



        Thanks for any insight,
        Adrian



    --     Adrian Klaver
    adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>




--
Adrian Klaver
adrian.klaver@aklaver.com

Re: [GENERAL] PSQL command line print speed

От
Francisco Olarte
Дата:
Adrian:

On Wed, May 17, 2017 at 6:03 PM, Adrian Myers <hadrianmyers@gmail.com> wrote:
> Queries which perform in a few milliseconds through a driver (psycopg2 in
> this case) can take several seconds or minutes to complete in the console,
> seemingly just due to it printing lines at a very leisurely pace (in other
> words, this is not the delay caused by the query itself, often it starts
> printing almost instantly but spends a very long time just writing output).
> While overall application performance is unaffected, simple admin tasks and
> poking around the data take longer than I would like as a result. Is there
> any way to improve just the display/write performance in the console?

Are you sure the culprit is psql and not you terminal emulator ?


Francisco Olarte.-


Re: [GENERAL] PSQL command line print speed

От
Adrian Klaver
Дата:
On 05/17/2017 09:46 AM, Adrian Myers wrote:
> Ah I should have mentioned, the pager is off.

Is that by choice and if so why?

With the pager off you have to wait for the entire output to write to
the screen. For anything but a small dataset that is going to take time.



--
Adrian Klaver
adrian.klaver@aklaver.com


Re: [GENERAL] PSQL command line print speed

От
Francisco Olarte
Дата:
CCing the list.

Adrian:

On Wed, May 17, 2017 at 6:58 PM, Adrian Myers <hadrianmyers@gmail.com> wrote:
> That is a great question, and no, I'm not. This is on Windows and I see this
> with normal cmd.exe and ConEmu but I have been using ConEmu for some time
> and have not looked into settings there. Thanks for that suggestion.

I do not know what ConEmu is, and have being out of windows since w2k.
But I do remember that, although windows console windows where great (
when using their api ) their terminal  emulation capabilities where
not that good, and some times they did things like slow ( aka "smooth"
) scroll and similar things which greatly impaired their performance.

I would test that ConEmu with some simple program. If you have a
classic cat it would be nice ( not type, which is internal, or any
windows program which maybe skipping stdin and goin directly to the
console api , even a simple 'while((c=getc())!=EOF) putc(c)' should be
fast if the console/redirections is not playing tricks.

You can also test with a single table, single text field, put a
several pages text value there and select it. If it is slow, I would
bet for terminal emulator problems.

Francisco Olarte.


Re: [GENERAL] PSQL command line print speed

От
Francisco Olarte
Дата:
Adrian:

On Wed, May 17, 2017 at 8:40 PM, Adrian Klaver
<adrian.klaver@aklaver.com> wrote:
> On 05/17/2017 09:46 AM, Adrian Myers wrote:
>> Ah I should have mentioned, the pager is off.
> Is that by choice and if so why?
>
> With the pager off you have to wait for the entire output to write to the
> screen. For anything but a small dataset that is going to take time.

Are you sure? IIRC hespecifically said the output started promptly but
was slow, i.e. speed, not latency problems as your are hinting.

And, IIRC again, psql uses libpq which always buffer the entire
response to the queries.

And nothing prohibits you from starting the output as soon as you can
calculate it even if no pager there ( note you have to make things
like calculate column widths, but this is done with and without pager
). In fact normally the pager will just introduce an small but
potentially noticeable delay.

Francisco Olarte.