Re: [PERFORM] Q on views and performance

2008-02-26 Thread Kynn Jones
On Mon, Feb 25, 2008 at 11:56 AM, Matthew [EMAIL PROTECTED] wrote: On Mon, 25 Feb 2008, Kynn Jones wrote: This is just GREAT!!! It fits the problem to a tee. It makes the queries quick then? It is good that you ask. Clearly you know the story: a brilliant-sounding optimization that in

Re: [PERFORM] Q on views and performance

2008-02-25 Thread Matthew
On Fri, 22 Feb 2008, Kynn Jones wrote: Hi. I'm trying to optimize... (Q1) SELECT a1.word, a2.word FROM T a1 JOIN T a2 USING ( zipk ) WHERE a1.type = int1 AND a2.type = int2; Okay, try this: Create an index on T(type, zipk), and then CLUSTER on that index. That

Re: [PERFORM] Q on views and performance

2008-02-25 Thread Matthew
So, this email is directed much more towards Postgres Powers That Be. I came across this problem a while ago, and I haven't checked whether it has been improved. On Mon, 25 Feb 2008, I wrote: Hi. I'm trying to optimize... (Q1) SELECT a1.word, a2.word FROM T a1 JOIN T a2 USING (

Re: [PERFORM] Q on views and performance

2008-02-25 Thread Kynn Jones
On Mon, Feb 25, 2008 at 8:45 AM, Matthew [EMAIL PROTECTED] wrote: On Fri, 22 Feb 2008, Kynn Jones wrote: Hi. I'm trying to optimize... (Q1) SELECT a1.word, a2.word FROM T a1 JOIN T a2 USING ( zipk ) WHERE a1.type = int1 AND a2.type = int2; Okay, try this:

Re: [PERFORM] Q on views and performance

2008-02-25 Thread Matthew
On Mon, 25 Feb 2008, Kynn Jones wrote: This is just GREAT!!! It fits the problem to a tee. It makes the queries quick then? Matthew -- The only secure computer is one that's unplugged, locked in a safe, and buried 20 feet under the ground in a secret location...and i'm not even too sure

Re: [PERFORM] Q on views and performance

2008-02-23 Thread Kynn Jones
On Fri, Feb 22, 2008 at 8:48 PM, Dean Gibson (DB Administrator) [EMAIL PROTECTED] wrote: On 2008-02-22 12:49, Kynn Jones wrote: Of course, I expect that using views Vint1 and Vint2... would result in a loss in performance relative to a version that used bona fide tables Tint1 and Tint2.

Re: [PERFORM] Q on views and performance

2008-02-23 Thread Kynn Jones
On Fri, Feb 22, 2008 at 8:48 PM, Dean Gibson (DB Administrator) [EMAIL PROTECTED] wrote: On 2008-02-22 12:49, Kynn Jones wrote: Of course, I expect that using views Vint1 and Vint2... would result in a loss in performance relative to a version that used bona fide tables Tint1 and Tint2.

Re: [PERFORM] Q on views and performance

2008-02-23 Thread Dean Gibson (DB Administrator)
On 2008-02-23 05:59, Kynn Jones wrote: On Fri, Feb 22, 2008 at 8:48 PM, Dean Gibson (DB Administrator) [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: ... Since you have experience working with views, let me ask you this. The converse strategy to the one I described originally would

Re: [PERFORM] Q on views and performance

2008-02-23 Thread Dean Gibson (DB Administrator)
On 2008-02-23 07:08, Dean Gibson (DB Administrator) wrote: ... SELECT word1, word1 FROM S JOIN txt ON word = word1 WHERE type1 = int1 AND type2 = int2; ... Oops that should be: SELECT word1, word2 FROM S JOIN txt ON word = word1 WHERE type1 = int1 AND type2 = int2; -- Mail to my

Re: [PERFORM] Q on views and performance

2008-02-23 Thread Kynn Jones
Hi, Dean. The system I'm working with is very similar in spirit to a large multilingual dictionary covering 100 languages. Using this analogy, the type column would correspond to the language, and the zipk column would correspond to some language-independent key associated with a concept

Re: [PERFORM] Q on views and performance

2008-02-23 Thread Dean Gibson (DB Administrator)
On 2008-02-23 08:21, Kynn Jones wrote: ... 3. Why not write: CREATE VIEW txt AS SELECT a1.word AS word1, a1.type AS type1, a2.word AS word2, a2.type AS type2 FROM T a1 [LEFT] JOIN T a2 USING( zipk ); -- Use LEFT if appropriate SELECT word1, word1 FROM S

Re: [PERFORM] Q on views and performance

2008-02-23 Thread Dean Gibson (DB Administrator)
On 2008-02-23 08:49, Dean Gibson (DB Administrator) wrote: Why 10,000 views??? What's wrong with the ONE view above? You DON'T want to be defining VIEWs based on actual tables VALUES; leave that to the SELECT. For that matter, what's wrong with the final SELECT I listed (below)? SELECT

[PERFORM] Q on views and performance

2008-02-22 Thread Kynn Jones
Hi. I'm trying to optimize the performance of a database whose main purpose is to support two (rather similar) kinds of queries. The first kind, which is expected to be the most common (I estimate it will account for about 90% of all the queries performed on this DB), has the following general

Re: [PERFORM] Q on views and performance

2008-02-22 Thread Dean Gibson (DB Administrator)
On 2008-02-22 12:49, Kynn Jones wrote: Of course, I expect that using views Vint1 and Vint2... would result in a loss in performance relative to a version that used bona fide tables Tint1 and Tint2. My question is, how can I minimize this performance loss? That used to be my thoughts too,