Article View: borland.public.interbase.sql
Article #838Re: Performance: Best strategy for non-PK and non-alphabetical sort order for rows?
From: Mitch
Date: Wed, 23 May 2007 18:53
Date: Wed, 23 May 2007 18:53
41 lines
2765 bytes
2765 bytes
Wayne Niddery [TeamB] wrote: > 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. > Thanks. Mitch
Technical Details
Message-ID:
<46548dc2$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<46540e25$1@newsgroups.borland.com> <46546613$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 Date: Wed, 23 May 2007 19:53:52 +0100 From: Mitch <mmm@yyy.com> User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 Newsgroups: borland.public.interbase.sql Subject: Re: Performance: Best strategy for non-PK and non-alphabetical sort order for rows? References: <46540e25$1@newsgroups.borland.com> <46546613$1@newsgroups.borland.com> In-Reply-To: <46546613$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 81.168.44.170 Message-ID: <46548dc2$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1179946434 81.168.44.170 (23 May 2007 11:53:54 -0700) Lines: 41 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail