Alex Katebi wrote: > However there are two things I don't like about this method. One is that I > need to parse the prepared statments and prefix queries, and replace the > table name with the temp table name in the surrogate query. Two is that if > the client does lots of queries before disconnecting from the server it > can waste whole lot of memory. Three is that it is a hack. >
Alex, There should be no need to parse the queries other than to check for "select" at the beginning to identify it as a select statement. All select statements would be prefixed with the same prefix string, "create tmp.result as", regardless of the complexity of the original query. You are simply storing the result set of the query into a temp table. Since the temporary result table is always the same, the surrogate query is always the same, "select * from from tmp.result". There is no need to replace any table names. I imagined the temporary memory database would be closed, and hence its memory released, after each query completes. The memory footprint wouldn't grow with each query, it would be the same as that required for the query with the largest result set. It is not a hack of any sort. It simply uses the public APIs to quickly copy the result data into a private table to avoid locking the entire database while those results are slowly scanned by a client. Dennis Cote _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users