BUG #1697: Select getting slower on continously updating data - Mailing list pgsql-bugs

From Bahadur Singh
Subject BUG #1697: Select getting slower on continously updating data
Date
Msg-id 20050602110500.59D47F0B00@svr2.postgresql.org
Whole thread Raw
Responses Re: BUG #1697: Select getting slower on continously updating data
List pgsql-bugs
The following bug has been logged online:

Bug reference:      1697
Logged by:          Bahadur Singh
Email address:      bahadursingh@yahoo.com
PostgreSQL version: 8.0
Operating system:   Windows 2000 server
Description:        Select getting slower on continously updating data
Details:

Hello,

I found situtation that, when I am selecting data from a table of 200
records, getting slower as I do continous update to the same existing data.



CREATE TABLE salesarticle
(
  articlenumber char(20) NOT NULL,
  price int4 NOT NULL,
  eodid int4 NOT NULL,
  departmentnumber char(4) NOT NULL,
  keycounter int4 NOT NULL,
  scancounter int4 NOT NULL,
  grosssalescounter int8 NOT NULL,
  grosssalesamount int8 NOT NULL,
  discountcounter int8 NOT NULL,
  discountamount int8 NOT NULL,
  reductioncounter int8 NOT NULL,
  reductionamount int8 NOT NULL,
  transactioncounter int4 NOT NULL,
  promotionamount int8 NOT NULL,
  promotioncounter int8 NOT NULL,
  datelastsale char(14) NOT NULL,
  CONSTRAINT salesarticle_pkey PRIMARY KEY (articlenumber, price, eodid),
  CONSTRAINT salesarticle_eodid_fkey FOREIGN KEY (eodid) REFERENCES eodinfo
(eodid) ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH OIDS;

This is my select statement:

EXPLAIN ANALYZE
SELECT ArticleNumber, Price, EodId FROM SalesArticle WHERE ArticleNumber IN
('                 9502',
'                9500','                9501','                9505','
         9506','                9507','                9515',
'                9516','                9518','                9520','
         9472','                9508','                9546',
'                3322','                9521' ) AND EodId = 12
"Index Scan using salesarticle_pkey, salesarticle_pkey, salesarticle_pkey,
salesarticle_pkey, salesarticle_pkey, salesarticle_pkey, salesarticle_pkey,
salesarticle_pkey, salesarticle_pkey, salesarticle_pkey, salesarticle_pkey,
salesarticle_pkey, salesarticl (..)"
"  Index Cond: ((articlenumber = '                 9502'::bpchar) OR
(articlenumber = '                9500'::bpchar) OR (articlenumber = '
         9501'::bpchar) OR (articlenumber = '                9505'::bpchar)
OR (articlenumber = '               (..)"
"  Filter: (eodid = 12)"
"Total runtime: 47.000 ms"

The first iteration(400 times selects and update that selected data ) say
400 are within 2 sec, then it keep on increasing at the end, it take 9
seconds to execute 100 selects and updates on the database. No new records
are added during this operation.

perfromace of above select degrade as follows
 = 16 ms  ==> yealds 1600 ms for 100 iteration.
 = 32 ms ==> yealds 3200 ms for 100 it...
 = 47 ms ==> yealds 4700 ms for 100 it...
 = 80 ms ==> yealds 80000 ms for 100 it...
 = 104 ms ==> yealds 10400 ms for 100 it...

when I create an index on PK of this table, it boosts select performance to
16 ms, but update stmts are slowing down. I do insert only once in begining
and then update them continously as long I recieve same input data. (means
no insert take place in between on this salesArticle table.)

Please advice me some solution or any trick.


Thanks in Advance,
Bahadur

pgsql-bugs by date:

Previous
From: Martin Pitt
Date:
Subject: More graceful handling of invalid log_*_stats conf in 7.4
Next
From: Bruno Wolff III
Date:
Subject: Re: BUG #1697: Select getting slower on continously updating data