EnterpriseDB: The Enterprise Postgres Company Postgres Plus Forums: The PostgreSQL Open Source Database from EnterpriseDB
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 

Patch to speed up table creation  XML

Forum Index » GridSQL - Developers
Author Message
David_

Member

Joined: 10 Apr 2008 16:25:24
Messages: 25
Offline

The code below reduces the time needed to create a table, like the following, by an order of magnitude:
create table testpartitioning_partitioned (da varchar(40) NOT NULL) partitioning key da on all;

It is especially true if the coordinator is run on a node without any database (as in my testing environment).

When creating a table, 256 queries of the following type are currently run:
INSERT INTO xsystabparthash (parthashid, tableid, dbid, hashValue, nodeid) VALUES (254, 2, 1, 253, 2)
INSERT INTO xsystabparthash (parthashid, tableid, dbid, hashValue, nodeid) VALUES (255, 2, 1, 254, 3)
INSERT INTO xsystabparthash (parthashid, tableid, dbid, hashValue, nodeid) VALUES (256, 2, 1, 255, 1)

The code below merges this into a single query like the following:
INSERT INTO xsystabparthash (parthashid, tableid, dbid, hashValue, nodeid) VALUES (254, 2, 1, 253, 2), (255, 2, 1, 254, 3), (256, 2, 1, 255, 1)

The following is the only method, which needs to change. It is located in the HashPartitionMap class:


This message was edited 1 time. Last update was at 23 Feb 2010 14:32:38

Mason_S

Senior member

Joined: 1 Apr 2008 09:03:08
Messages: 380
Offline

Thanks, David.

I appreciate you submitting a change.

I think we will hold off on adding this one for now since it may not be portable to other underlying databases. If we do add it, we would enable it by default and allow it to be turned off via the gridsql.conf file.

BTW, the reason why we bother inserting those rows is to make future repartitioning easier in the future, where we could move a subset of data to a new node, but that has not been implemented.

Regards,

Mason


[WWW]
David_

Member

Joined: 10 Apr 2008 16:25:24
Messages: 25
Offline

Hi Mason,

Thanks for the answer. I understand your reason for not adding the patch. For the record though, I will submit another one, which further increases the speed of creating a table, especially if the table has a lot of columns like mine. In my case it reduces 30 queries (one for each of my 30 columns) to one query. The only method to be changed is addTableColumns in MetaUtils.java.

One question, Mason. Is there any easier way for me to suggest changes to the code other than making a post here? I do not expect to be able to directly committ changes to the code, but being able to in some way make suggested changes to the code could be useful. Especially changes that affect more than one method or class.

This message was edited 2 times. Last update was at 25 Feb 2010 16:45:54

Mason_S

Senior member

Joined: 1 Apr 2008 09:03:08
Messages: 380
Offline

Hi David,

Please feel free to post any patches here.

If you prefer, you may also first privately send me a message.

Regards,

Mason
[WWW]
 
Forum Index » GridSQL - Developers
Go to:   
Powered by JForum 2.1.8 © JForum Team