Unix Technical Forum

What constitutes a complex query

This is a discussion on What constitutes a complex query within the Pgsql Performance forums, part of the PostgreSQL category; --> This falls under the stupid question and i'm just curious what other people think what makes a query complex? ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Performance

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-07-2008, 11:19 AM
Justin
 
Posts: n/a
Default What constitutes a complex query

This falls under the stupid question and i'm just curious what other
people think what makes a query complex?





--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-07-2008, 11:19 AM
Craig James
 
Posts: n/a
Default Re: What constitutes a complex query

Justin wrote:
> This falls under the stupid question and i'm just curious what other
> people think what makes a query complex?


There are two kinds:

1. Hard for Postgres to get the answer.

2. Hard for a person to comprehend.

Which do you mean?

Craig

--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-07-2008, 11:19 AM
Scott Marlowe
 
Posts: n/a
Default Re: What constitutes a complex query

On Tue, May 6, 2008 at 9:45 AM, Justin <justin@emproshunts.com> wrote:
> This falls under the stupid question and i'm just curious what other people
> think what makes a query complex?


Well, as mentioned, there's two kinds. some that look big and ugly
are actually just shovelling data with no fancy interactions between
sets. Some reporting queries are like this. I've made simple
reporting queries that took up many pages that were really simple in
nature and fast on even older pgsql versions (7.2-7.4)

I'd say that the use of correlated subqueries qualifies a query as
complicated. Joining on non-usual pk-fk stuff. the more you're
mashing one set of data against another, and the odder the way you
have to do it, the more complex the query becomes.

--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-07-2008, 11:19 AM
Steve Atkins
 
Posts: n/a
Default Re: What constitutes a complex query


On May 6, 2008, at 8:45 AM, Justin wrote:

> This falls under the stupid question and i'm just curious what other
> people think what makes a query complex?


If I know in advance exactly how the planner will plan the query (and
be right), it's a simple query.

Otherwise it's a complex query.

As I get a better feel for the planner, some queries that used to be
complex become simple.

Cheers,
Steve


--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-07-2008, 11:19 AM
Richard Broersma
 
Posts: n/a
Default Re: What constitutes a complex query

On Tue, May 6, 2008 at 9:41 AM, Scott Marlowe <scott.marlowe@gmail.com> wrote:
> I'd say that the use of correlated subqueries qualifies a query as
> complicated. Joining on non-usual pk-fk stuff. the more you're
> mashing one set of data against another, and the odder the way you
> have to do it, the more complex the query becomes.


I would add that data analysis queries that have multiple level of
aggregation analysis can be complicated also.

For example, in a table of racer times find the average time for each
team while only counting teams whom at least have greater than four
team members and produce an ordered list displaying the ranking for
each team according to their average time.


--
Regards,
Richard Broersma Jr.

Visit the Los Angles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 05-07-2008, 11:19 AM
Justin
 
Posts: n/a
Default Re: What constitutes a complex query



Craig James wrote:
> Justin wrote:
>> This falls under the stupid question and i'm just curious what other
>> people think what makes a query complex?

>
> There are two kinds:
>
> 1. Hard for Postgres to get the answer.

this one
>
> 2. Hard for a person to comprehend.
>
> Which do you mean?
>
> Craig
>


--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 05-07-2008, 11:19 AM
Scott Marlowe
 
Posts: n/a
Default Re: What constitutes a complex query

On Tue, May 6, 2008 at 11:23 AM, Justin <justin@emproshunts.com> wrote:
>
>
> Craig James wrote:
>
> > Justin wrote:
> >
> > > This falls under the stupid question and i'm just curious what other

> people think what makes a query complex?
> > >

> >
> > There are two kinds:
> >
> > 1. Hard for Postgres to get the answer.
> >

> this one


Sometimes, postgresql makes a bad choice on simple queries, so it's
hard to say what all the ones are that postgresql tends to get wrong.
Plus the query planner is under constant improvement thanks to the
folks who find poor planner choices and Tom for making the changes.

--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:41 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com