Re: Why does this array query fail? - Mailing list pgsql-general

From David Johnston
Subject Re: Why does this array query fail?
Date
Msg-id 1379474139935-5771367.post@n5.nabble.com
Whole thread Raw
In response to Re: Why does this array query fail?  (Ken Tanzer <ken.tanzer@gmail.com>)
Responses Re: Why does this array query fail?  (Ken Tanzer <ken.tanzer@gmail.com>)
List pgsql-general
Ken Tanzer wrote
> It's probably way more detail than you want, but I've attached the table
> structure and pasted in a quarterly report that the query above was taken
> from in case you have any pointers or are simply curious.

Is this a quarterly report because that is how long it takes to run?

On a smaller scale I've written queries like this.  I enrolled in a
university database design course shortly thereafter...

I would suggest considering how to use functions to encapsulate some of the
"medical code collecting" logic.  And consider WITH/CTE constructs as well,
like I used in my last message, to effectively create temporary named tables
for different parts of the query.

Might want to move the whole thing into function and pass in the various
parameters - namely the date range - instead of hard-coding the values into
the view.

Those thoughts aside I've done my own share of "write-once, read never"
queries and if the performance meets your needs and the maintenance burden
is acceptable then sometimes you just leave this in place until someone more
knowledgeable (like a future you probably) comes back and decides to toss
and rewrite it.

David J.





--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Why-does-this-array-query-fail-tp5771165p5771367.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


pgsql-general by date:

Previous
From: David Johnston
Date:
Subject: Re: Why does this array query fail?
Next
From: Albe Laurenz
Date:
Subject: Re: Something Weird Going on with VACUUM ANALYZE