Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 187F21C2F15 for ; Thu, 3 May 2012 14:08:53 -0300 (ADT) Received: from mail-qa0-f49.google.com ([209.85.216.49]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SPzWL-0000RV-N8 for pgsql-performance@postgresql.org; Thu, 03 May 2012 17:08:52 +0000 Received: by qabj40 with SMTP id j40so720357qab.1 for ; Thu, 03 May 2012 10:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type; bh=VNDAgWiDhJknjuSrsOmm7i50C9NveMnmck1w6/H1Re4=; b=ylsxI4CtsS1/LaGfkxaRdu1IctZP9/36BhfeMI003Ml1UyNuBZxNiiVCAPCX6aAv/F 1I1SnrFJcl6yop0WLzs7XxYiw0N5Vs2DGLoXuuaSKBR/bwNakSspUo19mqidpZJ8aRfk RzUMV/tdd954I4eB8vTYLRBz/piLjvQBjYwkXsoPJyN5snChm8CCVelcRsx406mTtox4 POdboiQ2WyabxpIthrZetn0j5Kijeoxjbstz9RGpv4wShH2iFTWc4y9N95vzcrsXJS/V C1MDuLu4IZDW6U5sIYoYtZgTsBoTfHK7PJEioSSCPSgNQVqtPuJcARa3WnO/l/NITOB9 CdFA== Received: by 10.229.135.202 with SMTP id o10mr1373431qct.84.1336064916315; Thu, 03 May 2012 10:08:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.135.10 with HTTP; Thu, 3 May 2012 10:07:55 -0700 (PDT) In-Reply-To: References: From: Eyal Wilde Date: Thu, 3 May 2012 20:07:55 +0300 X-Google-Sender-Auth: qmGaf5aL-jeWGrWPmDXaXAkU8F0 Message-ID: Subject: Re: scale up (postgresql vs mssql) To: pgsql-performance@postgresql.org Content-Type: multipart/alternative; boundary=00248c6a66babbdd3c04bf24da7b X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201205/42 X-Sequence-Number: 46866 --00248c6a66babbdd3c04bf24da7b Content-Type: text/plain; charset=UTF-8 guess what: after reducing bo (blocks out) to ~10% by using a ramdisk (improving overall performance by ~15-20%), i now managed to reduced it to ~3% by .... removing the "analyze temp-table" statements. it also : reduced b (Process which are waiting for I/O) to zero reduced wa (percentage of time spent by cpu for waiting to IO) to zero and reduced id (cpu idle time percent) to be 4 times less. r b swpd free buff cache si so bi bo in cs us sy id wa st 8 0 0 6144048 237472 485640 0 0 0 40 4380 3237 79 5 16 0 0 8 0 0 6138216 238032 485736 0 0 0 40 4741 3506 93 7 0 0 0 8 0 0 6125256 238276 486484 0 0 0 2709 4801 3447 92 7 1 0 0 7 0 0 6119400 238376 485792 0 0 0 32 4854 4311 93 6 1 0 0 5 0 0 6105624 238476 486172 0 0 0 364 4783 3430 92 7 1 0 0 5 0 0 6092956 238536 485384 0 0 0 416 4954 3652 91 8 2 0 0 unfortunately, this time there was no significant performance gain. ): i afraid now there are certain statements that do not use an optimal query-plan. these statements looks like: insert into temp-table1 (value) select table1.f1 from table1 join temp-table2 on table1.recid=temp-table2.recid where table1.f2 in (x,y,z); temp-table2 never contains more then 10 records. there is an index on table1: recid,f2 previous tests showed that the query-optimizer normally chose to do hash-join (i.e: ignoring the index), but once we did "analyze temp-table2;", the index was used. i read somewhere that the optimizer's assumption is that every temp-table contains 1k of records. i believe that is the reason for the bad plan. we tried to do "set enable_hashjoin=false;", but it did not seem to be working inside a function (although it did work independently). what can we do about that? another thing i found is that a sequence on a temp-table is being stored on the current tablespace, and not on the temp_tablespace. would you consider this as a bug? anyway, i found a way to not using any sequences on the temp-tables. but this did not change the bo (blocks-out) figures. merlin, about the Hint Bits. i read this article: http://wiki.postgresql.org/wiki/Hint_Bits as far as i understand, this is not the case here, because i ran the test many times, and there were no DML operations at all in between. so i believe that the hint-bits are already cleared in most of the tuples. Thanks again for any more help. --00248c6a66babbdd3c04bf24da7b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
guess what:

after reducing bo (blocks o= ut) to ~10% by using a ramdisk (improving overall performance by ~15-20%), = i now managed to reduced it to ~3% by .... removing the "analyze temp-= table" statements.=C2=A0
it also :
reduced b (Process which are waiting for I/O) to z= ero
reduced wa (percentage of time spent by cpu for waiting to IO= ) to zero
and reduced id (cpu idle time percent) to be 4 times le= ss.

r b swpd <= /span>free = buff cache<= span class=3D"Apple-tab-span" style=3D"white-space:pre"> si so bi bo in cs us= sy = id wa st
8 0 0 6144048 237472 485640 0 0 0 40 4380 3237 79 5 16 0 0
8 0 0 6138216 238032 485736 0 0 0 40= 4741 3506 93 7 0 0 0
8 0 0 6125256 238276 486484 0 0 0 2709 4801 3447 92= 7 1 0 0
7 0 0 6119400 238376 485792 0 0 0 32= 4854 4311 93 6 1 0 0
5 0 0 6105624 238476 486172 0 0 0 364 4783 3430 92<= span class=3D"Apple-tab-span" style=3D"white-space:pre"> 7 1 0 0
5 0 0 6092956 238536 485384 0 0 0 416 4954 3652 91<= span class=3D"Apple-tab-span" style=3D"white-space:pre"> 8 2 0 0


=09 =09 =09 =09
unfortunately, this time there was no significant performance ga= in. ):

i afraid now there are certain statements that do not use an optimal q= uery-plan. these statements looks like:
insert into temp-table1 (= value) select table1.f1 from table1 join temp-table2 on table1.recid=3Dtemp= -table2.recid where table1.f2 in (x,y,z);
temp-table2 never contains more then 10 records.
there is an= index on table1: recid,f2
previous tests showed that the query-o= ptimizer normally chose to do hash-join (i.e: ignoring the index), but once= we did "analyze temp-table2;", the index was used. i read somewh= ere that the optimizer's assumption is that every temp-table contains 1= k of records. i believe that is the reason for the bad plan. we tried to do= "set enable_hashjoin=3Dfalse;", but it did not seem to be workin= g inside a function (although it did work independently). what can we do ab= out that?

another thing i found is that a sequence on a temp-tabl= e is being stored on the current tablespace, and not on the temp_tablespace= . would you consider this as a bug?
anyway, i found a way to not = using any sequences on the temp-tables. but this did not change the bo (blo= cks-out) figures.

merlin,=C2=A0
about the Hint Bits. i read thi= s article:=C2=A0http:= //wiki.postgresql.org/wiki/Hint_Bits
as far as i understand, = this is not the case here, because i ran the test many times, and there wer= e no DML operations at all in between. so i believe that the hint-bits are = already cleared in most of the tuples.

Thanks again for any more help.
--00248c6a66babbdd3c04bf24da7b--