Solved

SPEEDING UP QUERY OR READING FROM A SINGLE TABLE

Posted on 1998-02-04
1
145 Views
Last Modified: 2010-04-04
I have a large database program that is really slow on querying because it is reading from multiple tables and using a tree to list the information. How can I speed this up or get it to read from a single table to speed it up?  I here is the code I am currently using.


var
   curNode : TTreeNode;
begin
   // Make sure report printing is disabled until a unit is selected
   mnuRepFeatures.Enabled:=false;
   mnuRepSpec.Enabled:=false;
   mnuPartIllus.Enabled:=false;
   mnuRepWriteup.Enabled:=false;
   mnuPartXRef.Enabled:=false;

   // Query Statuses set to false
   eqpSpecIllusQryStatus:=False;
   eqpSpecFeatureQryStatus:=False;
   eqpSpecDetailQryStatus:=False;
   partIllusQryStatus:=False;
   partKeysQryStatus:=False;
   writeupDetailQryStatus:=False;
   // TODO WSL Exception Handle
   curNode := seriesTreeView.Selected;
   pgctrlEqpDetail.ActivePage := tsCover;
   if (curNode.ImageIndex = 0) then
     pnlDescription.Caption := curNode.Text
   else
    begin
      pnlEqpDescription.Caption := curNode.Text;
      mnuRepFeatures.Enabled:=true;
      mnuRepSpec.Enabled:=true;
      mnuPartIllus.Enabled:=true;
      mnuRepWriteup.Enabled:=true;
      mnuPartXRef.Enabled:=false;
    end;
   StatusBar1.Panels[1].Text := curNode.Text;
   StatusBar1.Repaint;
   nbEqpDetail.PageIndex := curNode.ImageIndex;
end;

procedure TfrmMain.ExpandClick(Sender: TObject);
var
   tmpTreeNode : TTreeNode;
begin
   tmpTreeNode := seriesTreeView.Selected;
   if not (tmpTreeNode = nil) then
      tmpTreeNode.Expand(False);
end;

procedure TfrmMain.CollapseClick(Sender: TObject);
var
   tmpTreeNode : TTreeNode;
begin
   tmpTreeNode := seriesTreeView.Selected;
   if not (tmpTreeNode = nil) then
      tmpTreeNode.Collapse(False);
end;

procedure TfrmMain.FormShow(Sender: TObject);
var
   i : integer;
   d : double;
begin
   if (firstTime=false) then
      exit;
   firstTime:=false;
   strQueryStatus := 'Querying...';
   // Adjust column size to fit
   d := dbGridSpec.Width / 2.;
   i := Round(d);
   dbGridSpec.Columns.Items[0].Width:=i;
   dbGridSpec.Columns.Items[1].Width:=i;


Please answer ASAP....
0
Comment
Question by:aj85
1 Comment
 
LVL 3

Accepted Solution

by:
d4jaj1 earned 100 total points
ID: 1358252
Here's what I would suggest, use a TTable instead of a query.  If you have an index on teh table, use teh setRange function, as it is much faster that teh TQuery.  Furthermore, youshould speed things up with the table by opening it in exclusive mode. This way, teh BDE doesn't have to worry about periodically checking if other DB's need access.

If there is some reason you have to use a query (which I can't tell from your code), use the ORDER BY clause.  This will force teh query to use the available indexes. You must list the fields in the ORDER BY as they appear as indexes.  For example, if you have an index for FirstName-LastName, your ORDER BY clause must look like "ORDER BY FirstName, LastName;" for teh index to be used.  This is the only way (other than making sound your relationships are set up correctly) to speed up a query.

Any questions, please add a comment.  Good Luck!

Jay
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now