Re: very slow when writing query to file

From: Fernando Hevia <fhevia(at)gmail(dot)com>
To: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
Cc: boris pezzatti <boris(dot)pezzatti(at)wsl(dot)ch>, Francisco Leovey <fleovey(at)yahoo(dot)com>, "pgadmin-support(at)postgresql(dot)org" <pgadmin-support(at)postgresql(dot)org>
Subject: Re: very slow when writing query to file
Date: 2011-11-02 22:58:16
Message-ID: CAGYT1XTnu0K8_N_ORzV+y1aLCLVrC+RtXtFyiOaTndrkM_xPHw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

On Tue, Nov 1, 2011 at 07:23, Guillaume Lelarge <guillaume(at)lelarge(dot)info>wrote:

> [...]
>
> With 10k rows (2.3 MB) it took 3.5 seconds to retrieve data from DB and 40
> > seconds to write the file to an SATA 7200 disk with write-through cache.
> > With 100k rows (23 MB) the DB retrieve went for 35 seconds while the file
> > writing part took over 4 minutes (didn't wait for it to finish).
> >
>
> I don't have the same numbers:
>
> * 1000 : 1s
> * 10000 : 1s
> * 200000 : 7s
> * 1000000 : 18s
>
>
Interesting... seeing your explanation below, our timing difference
probably has to do with me testing on a table with lots of columns, many of
type timestamp and inet which I assume are costlier to convert. Boris,
might that be the case with you also?
I'll repeat my tests with a smaller and simpler table later.

> > The file is being written at an avg 60 KB per second, which is extremely
> > slow.
>
> If the only thing pgAdmin does was writing, I would agree. But,
> actually, it does a lot more things:
>
> * for each row
> * for each column
> * adds the column separator, if needed
> * grabs one cell's value
> * quotes the value, if needed (which also means doubling the quote
> if it's within the value)
> * adds the line separator
> * converts it to the encoding, if needed
> * writes it to the file
>
> That could take some time.
>

I see how I was completely underrating the workload involved in the file
writing process.

> I searched if there were some parts that took much longer than others,
> but failed to find one.
>

The effort is much appreciated. Thanks.

Regards,
Fernando.

In response to

Responses

Browse pgadmin-support by date

  From Date Subject
Next Message Julius Tuskenis 2011-11-03 07:17:49 Re: Bug, New Column... window, data type typing
Previous Message Guillaume Lelarge 2011-11-02 21:28:22 Re: Bug, New Column... window, data type typing