X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4B5A8D7A5E for ; Fri, 26 Aug 2005 20:31:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24101-04 for ; Fri, 26 Aug 2005 23:31:50 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 993EFD7705 for ; Fri, 26 Aug 2005 20:31:49 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7QNVpGB026746; Fri, 26 Aug 2005 19:31:51 -0400 (EDT) To: =?ISO-8859-1?Q?=DCmit_=D6ztosun?= Cc: pgsql-performance@postgresql.org Subject: Re: Weird performance drop after VACUUM In-reply-to: <1125093859.9329.30.camel@localhost.localdomain> References: <1125093859.9329.30.camel@localhost.localdomain> Comments: In-reply-to =?ISO-8859-1?Q?=DCmit_=D6ztosun?= message dated "Sat, 27 Aug 2005 01:04:19 +0300" Date: Fri, 26 Aug 2005 19:31:51 -0400 Message-ID: <26745.1125099111@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200508/461 X-Sequence-Number: 14208 =?ISO-8859-1?Q?=DCmit_=D6ztosun?= writes: > We are using PostgreSQL for our business application. Recently, during > testing of our application with large volumes of data, we faced a weird > problem. Our query performance dropped *dramatically* after "VACUUM FULL > ANALYZE" command. I think the problem is that the planner is underestimating the cost of evaluating this complicated filter condition: > -> Seq Scan on scf_irsaliye irs (cost=0.00..30.00 rows=1 width=20) (actual time=0.290..0.290 rows=0 loops=10000) > Filter: (((karsifirma)::text = 'KENDI'::text) AND (((turu)::text = 'MAI'::text) OR ((turu)::text = 'KGI'::text) OR ((turu)::text = 'PS'::text) OR ((turu)::text = 'TS'::text) OR ((turu)::text = 'KC'::text) OR ((turu)::text = 'KCO'::text)) AND (((_key_sis_depo_dest)::text = '$$$$0000003l$1$$'::text) OR ((_key_sis_depo_dest)::text = '$$$$00000048$1$$'::text) OR ((_key_sis_depo_dest)::text = '$$$$0000004b$1$$'::text) OR ((_key_sis_depo_dest)::text = '$$$$0000004d$1$$'::text)) AND (tarih <= '2005-08-26'::date)) While you could attack that by raising the cpu_operator_cost parameter, it would also be worth inquiring *why* the condition is so expensive to evaluate. I am suspicious that you are running the database in a locale in which strcoll() is really slow. Can you run it in C locale instead, or do you really need locale-aware behavior? Can you switch to a different database encoding? (A single-byte encoding such as Latin1 might be faster than UTF8, for example.) Another possibility is to take a hard look at whether you can't simplify the filter condition, but that'd require more knowledge of your application than I have. Or you could just play with the order of the filter conditions ... for example, the date condition at the end is probably far cheaper to test than the text comparisons, so if that's fairly selective it'd be worth putting it first. regards, tom lane