Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 65613B5DC48 for ; Mon, 29 Aug 2011 06:19:05 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 02185-02 for ; Mon, 29 Aug 2011 09:18:58 +0000 (UTC) X-Greylist: delayed 00:05:18.023203 by SQLgrey-1.7.6 Received: from nm5-vm1.bullet.mail.ird.yahoo.com (nm5-vm1.bullet.mail.ird.yahoo.com [77.238.189.202]) by mail.postgresql.org (Postfix) with SMTP id 6823CB5DC1E for ; Mon, 29 Aug 2011 06:18:58 -0300 (ADT) Received: from [77.238.189.52] by nm5.bullet.mail.ird.yahoo.com with NNFMP; 29 Aug 2011 09:13:39 -0000 Received: from [212.82.108.244] by tm5.bullet.mail.ird.yahoo.com with NNFMP; 29 Aug 2011 09:13:39 -0000 Received: from [127.0.0.1] by omp1009.mail.ird.yahoo.com with NNFMP; 29 Aug 2011 09:13:39 -0000 X-Yahoo-Newman-Property: ymail-5 X-Yahoo-Newman-Id: 403437.80874.bm@omp1009.mail.ird.yahoo.com Received: (qmail 65973 invoked by uid 60001); 29 Aug 2011 09:13:39 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.pl; s=s1024; t=1314609219; bh=bn1v+0kbqOCue549wdkMe+e25pyk2B3Vq9SRKx+dZgg=; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=TIhuyoItLEsVwKk6SB8m00yWOMr5PzDj6RSmvdncv/8TDR+vPjMiEQxgZWG60NjMxK1jDgjyjPGEid/dwZBJIiFsgTJeyNsyqQQbE35BSbOdgE6lxVKMfNE9EQktT9k3GXT85Cp2PyfFN3cruMvRd6oTobSe258VGtVKsz/2jeM= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.pl; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=raCs9OT4bJodOS52xPM4+CcPUt/OiVo1EpSrInCx0qRnIsOVWVmS8AxPoZBsSjcOU2F/7nYSwTJhS3QFevzkb+FhnN8i0n4tnIzrQNaPX3uMdZqcbGFIHBZzgVJJ/GnjevniYs8E7em15JlDsg8HG7lbIbQTu5XYZcL3vtAfqbI=; X-YMail-OSG: Zd3SIpoVM1k0NuDnsYLZJzyw6S_WgZkKPMQbwqB3kf8aABk tgCoK6N_GG9rmvBtBPkZ_9ghaZBmM4J1WpkRGZZHZM9U6VSOaAqWoaNnuPj3 7ci3OaqLVO0l6geuWqtWa7NDT032EFi.2a1JYehOI6U.oTvVkTXpKq7M5yeK EC4Vknn_JaZ.t9wrPhHDfzxEmsS7FPMwNJijmKbtXlAfDpnXXbk1Hm1LhkeH WfriDAq0jir9Z0qcZJM_WVF7irM2YnsaDk.WhDLiua4uxUKrf2DNT4uHmorr 643wqYY5MN45F9Er2TVSvJNk5FFKHYxr786WgZpl5jB_WZu.xXCWVC0DPonY e4ajS1to5nT1CjxO2 Received: from [77.247.181.164] by web132406.mail.ird.yahoo.com via HTTP; Mon, 29 Aug 2011 10:13:39 BST X-Mailer: YahooMailWebService/0.8.113.315625 Message-ID: <1314609219.14319.YahooMailNeo@web132406.mail.ird.yahoo.com> Date: Mon, 29 Aug 2011 10:13:39 +0100 (BST) From: Tasdassa Asdasda Reply-To: Tasdassa Asdasda Subject: Performance with many updates To: "pgsql-performance@postgresql.org" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-90869122-1314609219=:14319" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.647 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=0.1, FREEMAIL_FROM=0.001, FREEMAIL_REPLYTO_END_DIGIT=1.151, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201108/294 X-Sequence-Number: 44741 --0-90869122-1314609219=:14319 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi. I have a table called work (id bigserial, userid int4, kind1 enum, kind= 2 enum, kind3 enim, value bigint, modified timestamp)=0ATable will have abo= ut 2*10^6 rows (at same time - overall it can have higher IDs but old recor= ds are eventually deleted (moved to separate archive table) therefore the I= Ds can grow huge). After insert on table work, every row will be updated (v= alue will be reduced, till value =3D 0 (work is finished)). For each row th= ere will be from 1 to =0Amaybe 10 updates on two cells (value, modified). A= fter work is completed (value =3D 0) it's record will be moved to archive t= able.=0Akind1 is an enum with two values (a and b)=0Ai'm using:=0A- alter t= able work set fillfactor 50=0A- btree index on value, fillfactor 50=0A- btr= ee index on kind1, fillfactor 50=0A=0Amy question:=0A1. what can i do to pe= rform this selects faster:=0ASELECT id, value FROM work WHERE value>=3D$1 A= ND kind1=3D$2 AND kind2=3D$3 AND kind3=3D$4 FOR UPDATE;=0ASELECT id, value = FROM work WHERE userid=3D$1 AND kind1=3D$1 AND kind2=3D$3 AND kind3=3D$4 FO= R UPDATE;=0A2. How about inheriting and partitioning? I'm thinking about cr= eating two tables, one for kind1(a) and second for kind1(b), will it help i= n performance?=0A3. Is btree best for index on enum?=0A4. How about creatin= g index on complex keys like (user_id,kind1,kind2,kind3) and (price,kind1,= kind2,kind3)? =0A=0A=0AI have PostgreSQL 9.0.4.=0AThanks in advance=0A --0-90869122-1314609219=:14319 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hi. I have a tab= le called work (id bigserial, userid int4, kind1 enum, kind2 enum, kind3 en= im, value bigint, modified timestamp)
Table will have about 2*10^6 rows = (at same time - overall it can have higher IDs but old records are eventual= ly deleted (moved to separate archive table) therefore the IDs can grow hug= e). After insert on table work, every row will be updated (value will be re= duced, till value =3D 0 (work is finished)). For each row there will be fro= m 1 to
maybe 10 updates on two cells (value, modified). After work is c= ompleted (value =3D 0) it's record will be moved to archive table.
kind1= is an enum with two values (a and b)
i'm using:
- alter table work s= et fillfactor 50
- btree index on value, fillfactor 50
- btree index = on kind1, fillfactor 50

my question:
1. what can i do to perform this selects faster:
SELECT id, value FROM work WHERE value>=3D$1 AN= D kind1=3D$2 AND kind2=3D$3 AND kind3=3D$4 FOR UPDATE;
SELECT id, value = FROM work WHERE userid=3D$1 AND kind1=3D$1 AND kind2=3D$3 AND kind3=3D$4 FO= R UPDATE;
2. How about inheriting and partitioning? I'm thinking about c= reating two tables, one for kind1(a) and second for kind1(b), will it help = in performance?
3. Is btree best for index on enum?
4. How about crea= ting index on complex keys like (user_id,kind1,kind2,kind3) and (price,kin= d1,kind2,kind3)?

I have PostgreSQL 9.0.4.
Thanks in advance
--0-90869122-1314609219=:14319--