views:

31

answers:

0

Hello all,

I am working on a filtering section with "large" tables and performance (for SELECT) is of great concern.

table_1 has 710,000 records and looks like this:
(PK) game_id
param_1
param_2
param_3

table_2 has 42,218,503 records and looks like this:
(PK) set_id
value_1
value_2

table_3 has 56,312,204 records and looks like this:
(PK) relation_id
game_id
set_id
box_1
box_2

Inserts are not common (once a week) but Selects are (many, daily).
3 types of searches are common:

  1. By table_1 only (using param_1, param_2, param_3)
  2. By table_3 only, providing the value_1 to search for
  3. A combination of both

Each search will return 20 games at most, and I am concerned about the 3d case, where they search for both param_1, param_2 and value_1, value_2 in table_1 and table_2. I do not want to use a SELECT...JOIN because of the size of the temporal tables (between the 3 tables data is over 10 GB). I can also cache content (since it should never change) to flat files with PHP. The routine I have been thinking about is as follows:
Step 1: SELECT the set_id
Step 2: SELECT all game_id from table_3 WHERE set_id = value from Step 1
Setp 3: Build the SELECT for table_1 WHERE game_id = values from Step 2

Ideas or comments on this approach? Any other way you think is better?

(Im not on a dedicated server -yet- and tables are in the 3d Normal Form)