Most efficient technique for temp table data?
Posted in 1997
I have the following problem, for which I've been experimenting with several approaches using stored procedures. I need to: - Make two independent selections out of table A - Take the cross-product of those two selections. - Look up the resulting pairs for any that appear in a table B (which selected pairs of row of A). The selections from A and their cross-product are temporary data, to be disposed of once the lookup in B is complete. There are several ways to approach storing this temporary data: - create temporary tables, dropping them when done - make inserts in a permanent working table, deleting the entries when done - write stored procedures that return mutiple rows (using RETURN WITH CONTINUE), and process the results in a calling procedure using FOREACH EXECUTE PROCEDURE I'm looking for advice on what's the most efficient method. I'm more concerned with optimizing the response time for an individual query than multiuser issues. (Most times only one user would be executing this procedure, so for instance I'm not too worried about lock contention issues between multiple users sharing a working table.) In test data that I'm working with, I have about 3000 rows in A and about 5000 in B. Typical hit on the original searches of A might be 5-20. Final results might be 1 to a dozen or so. (Real production data might scale this up by a factor of 2 or 3.) Would doing this in ESQL offer advantages over SPL or vice versa? For the final lookup in B: A has a serial column primary key, and each B includes two foreign key columns for the values of the primary keys of the pair rows in A. Is a composite index on the two columns in B be the best way to assure fastest match of pairs, or would there be any advantage in creating a single dependent column in B (say 32768*serialA1 + serialA2) and indexing it instead? Running Informix SE 7.1 under Unix.