![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
It's slow due to several things happening all at once. There are a lot of inserts and updates happening. There is periodically a bulk insert of 500k - 1 mill rows happening. I'm doing a vacuum anaylyze every hour due to the amount of transactions happening, and a vacuum full every night. All this has caused selects to be very slow. At times, a "select count(1)" from a table will take several mins. I don't think selects would have to wait on locks by inserts/updates would it? |
#12
| |||
| |||
|
|
You might not need to do the vacuum fulls that often. If the your hourly vacuums have a high enough fsm setting, they should be keeping the database from continually growing in size. At that point daily vacuum fulls are overkill and if they are slowing stuff down you want to run quickly, you should cut back on them. |
#13
| |||
| |||
|
|
How long does 100,000 rows take to insert exactly? I believe with the bulk inserts, 100k only takes a couple mins. |
#14
| |||
| |||
|
|
Hmm, that seems a bit slow. How big are the rows you are inserting? Have you checked the cpu and IO usage during the inserts? You will need to do some kind of cpu/IO monitoring to determine where the bottleneck is. |
|
What hardware is this on? Sorry if you specified it earlier, I can't seem to find mention of it. |
#15
| |||
| |||
|
|
On Wed, 20 Oct 2004 19:59:38 +0100, Gary Doades <gpd (AT) gpdnet (DOT) co.uk> wrote: Hmm, that seems a bit slow. How big are the rows you are inserting? Have you checked the cpu and IO usage during the inserts? You will need to do some kind of cpu/IO monitoring to determine where the bottleneck is. The bulk inserts don't take full cpu. Between 40% and 80%. On the other hand, a select will take 99% cpu. |
|
What hardware is this on? Sorry if you specified it earlier, I can't seem to find mention of it. It's on a P4 HT with 1,128 megs ram. |
#16
| |||||
| |||||
|
|
Is this the select(1) query? Please post an explain analyze for this and any other "slow" queries. |
|
I would expect the selects to take 99% cpu if all the data you were trying to select was already in memory. Is this the case in general? I can do a "select count(1)" on a 500,000 row table in about 1 second on a Athlon 2800+ if all the data is cached. It takes about 25 seconds if it has to fetch it from disk. |
|
I have just done a test by inserting (via COPY) of 149,000 rows in a table with 23 columns, mostly numeric, some int4, 4 timestamps. This took 28 seconds on my Windows XP desktop, Athlon 2800+, 7200 rpm SATA disk, Postgres 8.0 beta 2. It used around 20% to 40% cpu during the copy. The only index was the int4 primary key, nothing else. |
|
How does this compare? Disk system?? |
|
Regards, Gary. |
#17
| |||
| |||
|
|
On Wed, 20 Oct 2004 20:49:54 +0100, Gary Doades <gpd (AT) gpdnet (DOT) co.uk> wrote: Is this the select(1) query? Please post an explain analyze for this and any other "slow" queries. I think it took so long 'cause it wasn't cached. The second time I ran it, it took less than a second. How you can tell if something is cached? Is there a way to see what's in cache? |
|
What about the postgresql.conf config settings. This is what I have and why. sort_mem = 32768 This is default. |
#18
| |||
| |||
|
|
You will need to tell us the number of updates/deletes you are having. This will determine the vacuum needs. If the bulk of the data is inserted you may only need to analyze frequently, not vacuum. In order to get more help you will need to supply the update/delete frequency and the explain analyze output from your queries. |
![]() |
| Thread Tools | |
| Display Modes | |
| |