473,802 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Optimiser desicion bringing system to its knees?

Hi everyone,

My performance on a big mission critical system has recently collapsed,
and I've finally traced it down to the postgresql optimiser I think.
I'm running postgresql-7.2.1-2PGDG

The explains below make it clear I think. If I just change the table
declaration order, I get MASSIVELY better performance. I thought the
postgres optimiser was meant to make these desicions for me?

cop=# explain select sum(t1.quantity ) from Shipment t2,
LineItem t1 where (t1.shipmentId= t2.shipmentId) AND ((((t1.sku =
'1614') AND (t1.status = 0)) AND t1.productReser vationId is not null )
AND (t2.stage = 10));
NOTICE: QUERY PLAN:

Aggregate (cost=138079.92 ..138079.92 rows=1 width=20)
-> Nested Loop (cost=0.00..138 079.91 rows=1 width=20)
-> Seq Scan on lineitem t1 (cost=0.00..138 076.49 rows=1
width=12)
-> Index Scan using shipment_pkey on shipment t2
(cost=0.00..3.4 1 rows=1 width=8)

cop=# explain select sum(t1.quantity ) from LineItem t1 ,
shipment t2 where (t1.shipmentId= t2.shipmentId) AND ((((t1.sku = '1614')
AND (t1.status = 0)) AND t1.productReser vationId is not null ) AND
(t2.stage = 10));
NOTICE: QUERY PLAN:

Aggregate (cost=9.42..9.4 2 rows=1 width=20)
-> Nested Loop (cost=0.00..9.4 2 rows=1 width=20)
-> Index Scan using lineitem_sku_re servation_idx on lineitem
t1 (cost=0.00..6.0 0 rows=1 width=12)
-> Index Scan using shipment_pkey on shipment t2
(cost=0.00..3.4 1 rows=1 width=8)

NOTE : THE ONLY CHANGE ABOVE IS IN THE FROM CLAUSE.

Note that this is genereated SQL (from the MVCSoft CMP 2.0 EJB engine),
so unfortunately, I can't really do much about fixing it :((. If anyone
can tell me whether this is fixed or not already, I would be very grateful

TIA,

Craig

P.S. This is the second attempted delivery of this message.
subscribe-digest fails, so my first wasn't posted. If a duplicate
happens, I apologise.
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #1
5 1549
Hello,

Well the first thing I would ask is what does the optimizer do if you
are running a current version of PostgreSQL? Specifically either
7.3.4 or even 7.4RC1.

Sincerely,

Joshua Drake
Craig O'Shannessy wrote:
Hi everyone,

My performance on a big mission critical system has recently collapsed,
and I've finally traced it down to the postgresql optimiser I think.
I'm running postgresql-7.2.1-2PGDG

The explains below make it clear I think. If I just change the table
declaration order, I get MASSIVELY better performance. I thought the
postgres optimiser was meant to make these desicions for me?

cop=# explain select sum(t1.quantity ) from Shipment t2,
LineItem t1 where (t1.shipmentId= t2.shipmentId) AND ((((t1.sku =
'1614') AND (t1.status = 0)) AND t1.productReser vationId is not null )
AND (t2.stage = 10));
NOTICE: QUERY PLAN:

Aggregate (cost=138079.92 ..138079.92 rows=1 width=20)
-> Nested Loop (cost=0.00..138 079.91 rows=1 width=20)
-> Seq Scan on lineitem t1 (cost=0.00..138 076.49 rows=1
width=12)
-> Index Scan using shipment_pkey on shipment t2
(cost=0.00..3.4 1 rows=1 width=8)

cop=# explain select sum(t1.quantity ) from LineItem t1 ,
shipment t2 where (t1.shipmentId= t2.shipmentId) AND ((((t1.sku = '1614')
AND (t1.status = 0)) AND t1.productReser vationId is not null ) AND
(t2.stage = 10));
NOTICE: QUERY PLAN:

Aggregate (cost=9.42..9.4 2 rows=1 width=20)
-> Nested Loop (cost=0.00..9.4 2 rows=1 width=20)
-> Index Scan using lineitem_sku_re servation_idx on lineitem
t1 (cost=0.00..6.0 0 rows=1 width=12)
-> Index Scan using shipment_pkey on shipment t2
(cost=0.00..3.4 1 rows=1 width=8)

NOTE : THE ONLY CHANGE ABOVE IS IN THE FROM CLAUSE.

Note that this is genereated SQL (from the MVCSoft CMP 2.0 EJB engine),
so unfortunately, I can't really do much about fixing it :((. If anyone
can tell me whether this is fixed or not already, I would be very
grateful

TIA,

Craig

P.S. This is the second attempted delivery of this message.
subscribe-digest fails, so my first wasn't posted. If a duplicate
happens, I apologise.
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-222-2783 - jd@commandpromp t.com - http://www.commandprompt.com
Editor-N-Chief - PostgreSQl.Org - http://www.postgresql.org

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 12 '05 #2
Hi,

I'm not onsite, but I just heard back from a colleage that rushed in to
try exactly that. It does indeed seem to be fixed in 7.4RC1. I assume
this will be pretty stable, and there seems to be heaps of enhancements,
so I think I'll just skip 7.3.x. I'm not doing anything funky with
postgreSQL, but if someone has a good reason for me NOT putting 7.4RC1
onto a production system, please let me know ;)

Thanks for the reply, Joshua.

Craig

On Thu, 6 Nov 2003, Joshua D. Drake wrote:
Hello,

Well the first thing I would ask is what does the optimizer do if you
are running a current version of PostgreSQL? Specifically either
7.3.4 or even 7.4RC1.

Sincerely,

Joshua Drake
Craig O'Shannessy wrote:
Hi everyone,

My performance on a big mission critical system has recently collapsed,
and I've finally traced it down to the postgresql optimiser I think.
I'm running postgresql-7.2.1-2PGDG

The explains below make it clear I think. If I just change the table
declaration order, I get MASSIVELY better performance. I thought the
postgres optimiser was meant to make these desicions for me?

cop=# explain select sum(t1.quantity ) from Shipment t2,
LineItem t1 where (t1.shipmentId= t2.shipmentId) AND ((((t1.sku =
'1614') AND (t1.status = 0)) AND t1.productReser vationId is not null )
AND (t2.stage = 10));
NOTICE: QUERY PLAN:

Aggregate (cost=138079.92 ..138079.92 rows=1 width=20)
-> Nested Loop (cost=0.00..138 079.91 rows=1 width=20)
-> Seq Scan on lineitem t1 (cost=0.00..138 076.49 rows=1
width=12)
-> Index Scan using shipment_pkey on shipment t2
(cost=0.00..3.4 1 rows=1 width=8)

cop=# explain select sum(t1.quantity ) from LineItem t1 ,
shipment t2 where (t1.shipmentId= t2.shipmentId) AND ((((t1.sku = '1614')
AND (t1.status = 0)) AND t1.productReser vationId is not null ) AND
(t2.stage = 10));
NOTICE: QUERY PLAN:

Aggregate (cost=9.42..9.4 2 rows=1 width=20)
-> Nested Loop (cost=0.00..9.4 2 rows=1 width=20)
-> Index Scan using lineitem_sku_re servation_idx on lineitem
t1 (cost=0.00..6.0 0 rows=1 width=12)
-> Index Scan using shipment_pkey on shipment t2
(cost=0.00..3.4 1 rows=1 width=8)

NOTE : THE ONLY CHANGE ABOVE IS IN THE FROM CLAUSE.

Note that this is genereated SQL (from the MVCSoft CMP 2.0 EJB engine),
so unfortunately, I can't really do much about fixing it :((. If anyone
can tell me whether this is fixed or not already, I would be very
grateful

TIA,

Craig

P.S. This is the second attempted delivery of this message.
subscribe-digest fails, so my first wasn't posted. If a duplicate
happens, I apologise.
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #3
"Craig O'Shannessy" <cr***@ucw.com. au> writes:
The explains below make it clear I think. If I just change the table
declaration order, I get MASSIVELY better performance.


Hm. Is the lineitem_sku_re servation_idx index a partial index, by any
chance? I see this bug fix in 7.2.2:

2002-08-22 12:20 tgl

* src/backend/optimizer/path/indxpath.c (REL7_2_STABLE) : Back-patch
fix to make partial indexes usable on relations other than the
first one listed in a query. Per request from Oleg.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #4
Ahh, this makes sense.

I've recently changed this into a partial index because I was getting
awful performance on it.

Thanks Tom, this gives me a stopgap fix until I can get 7.4 into
production.

Craig

On Thu, 6 Nov 2003, Tom Lane wrote:
"Craig O'Shannessy" <cr***@ucw.com. au> writes:
The explains below make it clear I think. If I just change the table
declaration order, I get MASSIVELY better performance.


Hm. Is the lineitem_sku_re servation_idx index a partial index, by any
chance? I see this bug fix in 7.2.2:

2002-08-22 12:20 tgl

* src/backend/optimizer/path/indxpath.c (REL7_2_STABLE) : Back-patch
fix to make partial indexes usable on relations other than the
first one listed in a query. Per request from Oleg.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #5
In the last exciting episode, cr***@ucw.com.a u ("Craig O'Shannessy") wrote:
I'm not onsite, but I just heard back from a colleage that rushed in to
try exactly that. It does indeed seem to be fixed in 7.4RC1. I assume
this will be pretty stable, and there seems to be heaps of enhancements,
so I think I'll just skip 7.3.x. I'm not doing anything funky with
postgreSQL, but if someone has a good reason for me NOT putting 7.4RC1
onto a production system, please let me know ;)


Would you rush FreeBSD 5.1 into production when they're still
experimenting with it?

Would you rush Linux 2.6 into production when they still haven't got
the .0 release of that?

I'm doing some active work testing 7.4RC1 with some apps on the basis
that by the time the software is ready to deploy, PG will surely have
reached version 7.4.0 or 7.4.1. But if I planned something for
production TOMORROW (e.g. - as in Friday, November 7, the day after
today, November 6th), I would be looking at 7.3.4.

Don't misinterpret that as any sort of "vote of nonconfidence;" it's
just the notion of having a modicum of conservatism, and staying a
_small_ step away from the bleeding edge of the abyss, at least when
looking at production systems.

I similarly haven't yet had opportunity to test out Jan Wieck's ARC
patch, improving the way the system copes with VACUUM when under heavy
load. Of vast ultimate interest though it may be, I simply haven't
got a test set ready to _properly_ torture the patch, so it makes
sense to wait and maybe look at it a little later as it matures.

There's an old line about rushing in where angels fear to tread.
Putting not-yet-released software into production is one of those
places...
--
(format nil "~S@~S" "cbbrowne" "ntlug.org" )
http://www.ntlug.org/~cbbrowne/
Rules of the Evil Overlord #104. "My undercover agents will not have
tattoos identifying them as members of my organization, nor will they
be required to wear military boots or adhere to any other dress
codes." <http://www.eviloverlor d.com/>
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
324
by: Craig O'Shannessy | last post by:
Hi everyone, My performance on a big mission critical system has recently collapsed, and I've finally traced it down to the postgresql optimiser I think. I'm running postgresql-7.2.1-2PGDG The explains below make it clear I think. If I just change the table declaration order, I get MASSIVELY better performance. I thought the postgres optimiser was meant to make these desicions for me?
2
2424
by: Paul Reddin | last post by:
Hi, I'm sure I read somewhere that the SELECTIVITY Clause cannot be used with static SQL, can anybody confirm/deny this? Also, at the risk of a philosophical war, when will the optimizer provide for some real form of hints. It is so very,very painful and very,very time consuming trying to work around bad optimizer plans. I know IBM think it is
1
20982
by: Kevin Carter | last post by:
Hi there...hoping somebody can help me out because I am almost ready to pull out my hair. My problem is as follows: In a method in my main form (non MDI app), I instantiate and .Show another form. As a result of the .Show, the form's Load event is called and I have a population routine fires off. Normally, all is well and good and the new form is active and gets displayed on top of the main
3
3235
by: Richard L Rosenheim | last post by:
I have the application's form (MainForm) along with a 2nd form (Form2). If the user minimizes MainForm, I also minimize Form2. And when the user restores the application, I also restore Form2. But, Form2 is ending up behind MainForm. Anyone have an idea of how can I set/keep Form2 to be in front of the MainForm? And before someone suggests it, no -- I don't consider TopMost to be the solution. That will make the form the topmost...
0
1645
by: cvetomir.todorov | last post by:
We have an app which must be single instance. When we start the app we check if it is already running (using the Process object in the System.Diagnostics namespace) locating it by the name of the process. It is not the problem. When it is already running we have to maximize the already started application and bring it on top of other windows. When we find our process we get the main window handle from the Process object: IntPtr hWnd =...
3
2602
by: papalarge | last post by:
I have a VB.NET application that consists of a toolbar and a subwindow that I want to function together and not independently. So when I give focus to one, I want to make sure that the other is visible on the screen (brought to front, right behind the one in focus). I've played with the activated event of each form, but everything I've tried so far fails, as it's a pretty cyclical process that gets initiated. I'd love any help......
5
1558
by: amir | last post by:
Hello All, Just wanted to know if c# has a class which can handle communication between neighbour computers in same network so if i run a program on one computer it will be able to bring up processes and have all other properties of controling the state of that process through a service which is already running on windows... that is, without opening sockets ??? Thanks, Amir.
31
1792
by: Dave S | last post by:
Hi All, I have been given some code to wok on. It relies heavily on the optimiser to run at the correct speed. With this in mind I have been loking through it to see if I can help it out a bit. I have limitied knowledge of how compilers works, but I understand that some constructs optimise easier / better. We are using a variant of gcc (3.4.1 I think) on Nios II platform, if that makes a difference. The question I have is are these 2...
8
1529
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
I'm working with a microcontroller at the moment that has a single instruction for clearing a bit in a byte. I started off with the following line of code: x &= ~0x8u; /* Clear the 4th bit */ But then I changed it to the following because I thought I might get more efficient assembler out of it:
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10305
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9115
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.