Best PracticesLimiting SQL Queries


When generating reports, the ColdFusion Report Builder enables you to select as many fields into your SQL query as you would like. It then enables you to choose which of those fields you would actually like to display in the report. You therefore might be tempted to simply select every field from the database into your query and then filter out what you don't want to see with the Report Builder.

Be cautious in this approach. Remember that each time your page or report loads, the recordset is built. This means that if your database has 50 fields and 5,000 records, your SQL query will have to draw 25,000 pieces of data from the database. If, however, you determined that you wanted to display only 5 of those fields, your SQL query has to return only 2,500 pieces of datawhich decreases the amount of time it takes for your report to load.

So before you ever begin developing your SQL query, take some time to determine which fields you really need and which can be left alone to conserve load times.



Special Edition Using Macromedia Studio 8
Special Edition Using Macromedia Studio 8
ISBN: 0789733854
EAN: 2147483647
Year: 2003
Pages: 337

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net