rt

解决方案 »

  1.   

    在许多地方可以用到prepare,比如TQuery,TIBDataSet,要求数据库服务对当前的SQL语句进行优化,当一条查询被执行多遍的时候,调用prepare可以提高效率,具体的细节你可以查一下delphi的帮助TQuery.Prepareprocedure Prepare;DescriptionCall Prepare to have the BDE and a remote database server allocate resources for the query and to perform additional optimizations. Calling Prepare before executing a query improves application performance.Delphi automatically prepares a query if it is executed without first being prepared. After execution, Delphi unprepares the query. When a query will be executed a number of times, an application should always explicitly prepare the query to avoid multiple and unnecessary prepares and unprepares.Preparing a query consumes some database resources, so it is good practice for an application to unprepare a query once it is done using it. The UnPrepare method unprepares a query.Note: When you change the text of a query at runtime, the query is automatically closed and unprepared.