Unix Technical Forum

Performance of Views

This is a discussion on Performance of Views within the Pgsql General forums, part of the PostgreSQL category; --> Hello there, i have a short question ... I have a few tables (at the moment "only" 3 for ...


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

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 07:49 PM
Steffen Boehme
 
Posts: n/a
Default Performance of Views

Hello there,

i have a short question ...

I have a few tables (at the moment "only" 3 for testing), over which
will by made a query in this form:

SELECT
a.orderitem_id,
a.transaction_id,
a.order_id,
a.shop_id,
a.quantity,
a.price,
b.affiliate_id,
c."type"
FROM
ss_order_orderitems a
LEFT JOIN ss_order_affiliate_tracking b ON a.order_id = b.order_id,
ss_shops c
WHERE
(a.order_id = b.order_id OR b.order_id IS NULL) AND
a.shop_id = c.shop_id;

The query will get later a few more conditions ...

Now is the problem, that the performance is not realy good ... and i
think about the best solution for such a query and found three possibilitys:

1. a simple select over the three tables (one of them contains 160000
entrys in the moment and it's growing) in the form like above (the db is
mysql 4.1.x)
I think this solution is not very perfomant ...

2. move the data to a postgresql-db with the same structur and create a
view, wich makes the same query ...
Is the performance for the same query different between a simple select
and a view!?
If so, i can forget the view ...

3. put the data with the above query in one big table ...
I know, thats no good db-structur, but i don't know how i could make it
better ...


The main-question at the moment iss ...
Is the performance of the View-Method better then the first Method on
the existing tables!?

I hope of a view hints ...

Thanks
Steffen
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 07:51 PM
Greg Stark
 
Posts: n/a
Default Re: Performance of Views

Steffen Boehme <Steffen@boemm.de> writes:

> FROM
> ss_order_orderitems a
> LEFT JOIN ss_order_affiliate_tracking b ON a.order_id = b.order_id, ss_shops c
> WHERE
> (a.order_id = b.order_id OR b.order_id IS NULL) AND


What is that last line doing there? It's completely redundant and could very
well be the source of your problems.

For useful help you should post the \d output for the three tables and the
result of "EXPLAIN ANALYZE SELECT ...".

> The main-question at the moment iss ...
> Is the performance of the View-Method better then the first Method on
> the existing tables!?


A view doesn't change performance at all. It's exactly the same as writing the
query in the view directly into your query.

--
greg


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

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 12:49 AM.


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