473,788 Members | 2,820 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Performance weirdness with/without vacuum analyze

I asked earlier about ways of doing an UPDATE involving a left outer
join and got some very useful feedback.

This has thrown up a (to me) strange anomaly about the speed of such
an update.

The input to this query is a fairly large (the example I'm working
with has 335,000 rows) set of records containing numbers to be looked
up in the lookup table. This lookup table has 239 rows.

I'm always reading the suggestion that doing a 'VACUUM ANALYZE' on a
database is 'A Good Thing' as it helps the planner to do the best thing, so
I arranged a vacuum analyze on the input records.

Running the query takes about 13 mins or so.

If, however I *don't* do an analyze, but leave the input table as
it was when imported the run takes about 2.5 mins!

Looking at the output from 'explain' I can see that the main difference
in the way the planner does it is that it does a merge join in the non-analyze
case, and a hash join in the analyze case.

Unfortunately I don't really know what this is implying, hence the call
for assistance.

I have a file with all sorts of info about the problem (details of tables,
output of 'explain' etc) but as it is about 5K in size, and wide as well, I
didn't want to dump it in the list without any warning!

Regards,
Harry.
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org

Nov 12 '05 #1
3 1614
On Monday 13 October 2003 19:17, Harry Broomhall wrote:
I asked earlier about ways of doing an UPDATE involving a left outer
join and got some very useful feedback.

This has thrown up a (to me) strange anomaly about the speed of such
an update.

The input to this query is a fairly large (the example I'm working
with has 335,000 rows) set of records containing numbers to be looked
up in the lookup table. This lookup table has 239 rows.
Can yu lookup those 239 values in 335,000 rows instead. The result will be
same but probably it will be lot moer faster...
I'm always reading the suggestion that doing a 'VACUUM ANALYZE' on a
database is 'A Good Thing' as it helps the planner to do the best thing, so
I arranged a vacuum analyze on the input records.

Running the query takes about 13 mins or so.

If, however I *don't* do an analyze, but leave the input table as
it was when imported the run takes about 2.5 mins!
Thats weird..
Looking at the output from 'explain' I can see that the main difference
in the way the planner does it is that it does a merge join in the
non-analyze case, and a hash join in the analyze case.
Turn the comparison other way round as I suggested. See if that makes any
difference..

Unfortunately I don't really know what this is implying, hence the call
for assistance.

I have a file with all sorts of info about the problem (details of
tables, output of 'explain' etc) but as it is about 5K in size, and wide as
well, I didn't want to dump it in the list without any warning!


An explain analyze in both cases+postgresq l.conf tuning and hardware/software
information would be very good. Compress it before you post if you think its
too big..

HTH

Shridhar
---------------------------(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 #2
Shridhar Daithankar writes:
On Monday 13 October 2003 19:17, Harry Broomhall wrote: [SNIP]
The input to this query is a fairly large (the example I'm working
with has 335,000 rows) set of records containing numbers to be looked
up in the lookup table. This lookup table has 239 rows.


Can yu lookup those 239 values in 335,000 rows instead. The result will be
same but probably it will be lot moer faster...

I'm not entirely sure how I would do this, as the 'lookup' is actualy
a join. I thought that the order of nameing the joined tables didn't
matter (except for 'left' and 'right'), similar to the fact that 1 + 2 is
the same as 2 + 1.

[SNIP]
An explain analyze in both cases+postgresq l.conf tuning and hardware/software
information would be very good. Compress it before you post if you think its
too big..

This would amount to an attachment, and I'm not sure how this list views
such things.

I've emailed you the file separately.

Regards,
Harry.
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #3

Harry Broomhall <ha************ *@uk.easynet.ne t> writes:
I'm not entirely sure how I would do this, as the 'lookup' is actualy
a join. I thought that the order of nameing the joined tables didn't
matter (except for 'left' and 'right'), similar to the fact that 1 + 2 is
the same as 2 + 1.


Outer joins are commutative (1+2 == 2+1) at least barring the left/right
issue. But they are not associative. (1+2)+3 != 1+(2+3).

There are cases where the optimizer could prove a particular set of joins
could be reordered this way, but it doesn't know how to do that currently.

--
greg
---------------------------(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 #4

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

Similar topics

6
3496
by: Holger Marzen | last post by:
Hi all, the docs are not clear for me. If I want (in version 7.1.x, 7.2.x) to help the analyzer AND free unused space do I have to do a vacuum vacuum analyze or is a
11
6975
by: Dave [Hawk-Systems] | last post by:
have the table "numbercheck" Attribute | Type | Modifier -----------+------------+---------- svcnumber | integer | not null svcqual | varchar(9) | svcequip | char(1) | svctroub | varchar(6) | svcrate | varchar(4) | svcclass | char(1) | trailer | varchar(3) |
10
3182
by: Stephen | last post by:
Hello, Is it normal for plain VACUUM on large table to degrade performance by over 9 times? My database becomes unusable when VACUUM runs. From reading newsgroups, I thought VACUUM should only slow down by 10% to 15%. Other MVCC databases like MySQL InnoDB can even VACUUM discretely (runs internally). Is it my Linux system or is it PostgreSQL? The database is mostly read-only. There are 133,000 rows and each row is about 2.5kB in size...
6
2657
by: Alex | last post by:
Hi, just a few questions on the Vaccum I run a vacuum analyze on the database every night as part of a maintenance job. During the day I have a job that loads 30-70,000 records into two tables (each 30-70k). This job runs 2-3 times a day; the first time mainly inserts, the 2nd, 3rd time mostly updates.
5
7191
by: Gavin Scott | last post by:
Hi, I'm having a performance problem with a large database table we use with postgres 7.3.4. The table is: db=> \d log Table "public.log" Column | Type | Modifiers ---------+----------+----------- hid | integer |
0
2010
by: Rajesh Kumar Mallah | last post by:
Greeting, Will it be an useful feature to be able to vacumm / analyze all tables in a given schema. eg VACUUM schema.* ; at least for me it will be a good feature.
3
2091
by: Mario Soto | last post by:
Hi. i hava a postresql 7.4.2 in a production server. tha machine is a Pentium IV 2,6 GHZ AND 1 GB IN RAM with lINUX RH 9.0. The postresql.conf say: #--------------------------------------------------------------------------- # RESOURCE USAGE (except WAL) #---------------------------------------------------------------------------
16
1947
by: D. Stimits | last post by:
A non-profit organization is interested in a new data application that would use a SQL storage system. I'm interested to know how non-profit companies that are not selling products are considered for licensing. Can they use PostgreSQL just like anyone else or do non-profits qualify as commercial use and need to consider other licensing? D. Stimits, stimits AT comcast DOT net ---------------------------(end of...
22
3363
by: Kevin Murphy | last post by:
I'm using PG 7.4.3 on Mac OS X. I am disappointed with the performance of queries like 'select foo from bar where baz in (subquery)', or updates like 'update bar set foo = 2 where baz in (subquery)'. PG always seems to want to do a sequential scan of the bar table. I wish there were a way of telling PG, "use the index on baz in your plan, because I know that the subquery will return very few results". Where it really matters, I have...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10173
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...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
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
8993
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
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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.