Solved

SPEEDING UP QUERY OR READING FROM A SINGLE TABLE

Posted on 1998-02-04
1
151 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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