Home > database > Many tables in parallel and efficiency problem in many fields
Many tables in parallel and efficiency problem in many fields
Time:09-29
There are a lot of the same table (about 100) structure, including a device id field and built the index, now need a query about 2000 device id, how to query the data more quickly in the 100 table accords with a condition? I query now is SELECT * FROM table_name1 where (in device id1, id2 equipment,... , equipment id2000) UNION ALL SELECT * FROM table_name2 where (in device id1, id2 equipment,... , equipment id2000) . UNION ALL SELECT * FROM table_name100 where (in device id1, id2 equipment,... , equipment id2000)
But writing the query efficiency is too slow, often require several minutes, excuse me, how to optimize the better, Each table 1, 2, about one million data, Using a PostgreSQL database, but feel the man section is too little, so can only be sent to the plate,
CodePudding user response:
Try to find the values in a table, then the JOIN see efficiency
CodePudding user response:
The estimates that it is difficult to optimize the left index, the 100 * 2000 records of IO in this, need time,