Article View: borland.public.interbase.sql
Article #837Re: Performance: Best strategy for non-PK and non-alphabetical sort order for rows?
From: Wayne Niddery [TeamB]
Date: Wed, 23 May 2007 16:04
Date: Wed, 23 May 2007 16:04
42 lines
3079 bytes
3079 bytes
Mitch wrote: > > I need to enable my users to easily specify (and re-specify) a > position for each row relative to the others above and below it. I > therefore > can't use the primary key or other columns to sort by. I must use an > extra integer column where the sequence is defined by the integer. > > I am using the Developer Express grid to drag and drop the rows and > they have given me code which (upon an insert or drag) automatically > recalculates the sequence in the grid, often for all the rows in the > dataset. > > This is done on a row by row basis, so the process is very very slow > and gets slower as the number of rows in the dataset increases. Also, > in a multi-user situation I suspect this will be unworkable. Multiple users can compete on trying to order these rows? There's no good solution for that part. > Does anyone have any suggestions for accomplishing this in a way which > numbering is automatic for the user, but which maintains the > performance and efficiency of a database with > 10,000 rows. Use a grid that is not directly attached to the dataset. Could be a stringgird, drawgrid or listview. When the dataset is opened, load the rows into a list of your own objects and use these to display (I strongly recommend a drawgrid or virtual mode listview as this avoids copying data yet again to display it). When a user moves an item, you simply need to move that object in the list. When the user says he's done, you simply loop through the list *once* updating the sequence numbers in the database. Using a loop with a parameterized update statement within a single transaction should provide decent performance. -- Wayne Niddery - Winwright, Inc (www.winwright.ca) "Some see private enterprise as a predatory target to be shot, others as a cow to be milked, but few are those who see it as a sturdy horse pulling the wagon." - Winston Churchill
Technical Details
Message-ID:
<46546613$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!colt.net!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<46540e25$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,7ed325c4992c39f3 X-Google-Attributes: gid114a0e,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Wayne Niddery [TeamB]" <wniddery@chaffaci.on.ca> From: "Wayne Niddery [TeamB]" <wniddery@chaffaci.on.ca> Newsgroups: borland.public.interbase.sql References: <46540e25$1@newsgroups.borland.com> Subject: Re: Performance: Best strategy for non-PK and non-alphabetical sort order for rows? Date: Wed, 23 May 2007 12:04:35 -0400 Lines: 44 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3028 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 NNTP-Posting-Host: 69.17.170.228 Message-ID: <46546613$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1179936275 69.17.170.228 (23 May 2007 09:04:35 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!colt.net!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail