X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id C7AD69DC9D8 for ; Wed, 14 Dec 2005 18:06:46 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06706-04 for ; Wed, 14 Dec 2005 18:06:48 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from linux.dunaweb.hu (linux.dunaweb.hu [62.77.196.1]) by postgresql.org (Postfix) with ESMTP id B2C859DC898 for ; Wed, 14 Dec 2005 18:06:44 -0400 (AST) Received: from localhost (linux.dunaweb.hu [127.0.0.1]) by linux.dunaweb.hu (Postfix) with ESMTP id 820B08E0589; Wed, 14 Dec 2005 23:06:42 +0100 (CET) Received: from linux.dunaweb.hu ([127.0.0.1]) by localhost (linux.dunaweb.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 23415-01; Wed, 14 Dec 2005 23:06:41 +0100 (CET) Received: from szolnok.dunaweb.hu (unknown [192.168.3.154]) by linux.dunaweb.hu (Postfix) with ESMTP id 80DA38E0366; Wed, 14 Dec 2005 23:06:41 +0100 (CET) Received: from [81.17.177.202] (unknown [81.17.177.202]) by szolnok.dunaweb.hu (Postfix) with ESMTP id 18B418913CC; Wed, 14 Dec 2005 23:06:46 +0100 (CET) Message-ID: <43A09F1F.6030105@dunaweb.hu> Date: Wed, 14 Dec 2005 23:39:27 +0100 From: Zoltan Boszormenyi User-Agent: Mozilla Thunderbird 1.0.7-1.1.fc3 (X11/20050929) X-Accept-Language: hu-hu, hu, en-us, en MIME-Version: 1.0 To: PFC Cc: pgsql-performance@postgresql.org Subject: Re: Auto-tuning a VIEW? References: <43A08EF5.4060306@dunaweb.hu> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: amavisd-new at dunaweb.hu X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200512/334 X-Sequence-Number: 16155 PFC írta: > >> create view v1 (code,num) as >> select 'AAA',id from table1 >> union >> select 'BBB',id from table2; > > > As your rows are, by definition, distinct between each subquery, > you should use UNION ALL instead of UNION to save postgres the > trouble of hunting non-existing duplicates. This will save you a few > sorts. Thanks, now the SELECT from the huge VIEW runs under one third of the original runtime. >> select * from v1 where code||num = 'AAA2005000001'; > > > Why don't you use code='AAA' and num='2005000001' ? That's the point, the software environment we use cannot use it. The whole stuff is built on PowerBuilder 8.0.x, using PFC. The communication between the sheet and the response forms allows only one key field, and changing the foundation is risky. One particular application that uses the before mentioned VIEW with the huge UNION also cannot workaround the problem, that's why I asked it. The system is using Informix 9.21 and it's dog slow. I worked with PostgreSQL earlier, and my tests show that PostgreSQL 8.x is at least 5 times faster on normal queries than this other DBMS. So I am trying to port the database contents to PostgreSQL first and test some often used processing, to see whether it's feasible to switch later. Interestingly, the example query I provided runs about two times faster in Informix than in PostgreSQL. I experimented a little and found what I described. Best regards, Zoltán Böszörményi