Home > database >  If the where condition in the SQL query in the parameters in the more than one thousand or more gene
If the where condition in the SQL query in the parameters in the more than one thousand or more gene

Time:09-18

This query is similar to batch query, a parameter to carry multiple values, query the multiple records, have a great god can teach a few action in the face of this kind of question solution,

CodePudding user response:

In (1, 2, 3) or in (4, 5, 6)

CodePudding user response:

Insert the parameters into the temporary table, then associate the temporary table query

CodePudding user response:

In more than 300, performance will be serious decline, according to the 2 # advice, write temporary tables, relational query again,

CodePudding user response:

If built a temporary table to the database read and write operations are frequent, and requirements database to read and write performance is good, otherwise the query time will be longer,

CodePudding user response:

Won't, you to write so few data in the table, than in the performance of the decline, is nothing, can do the test,

CodePudding user response:

In back up to 999, performance degradation, Suggestions can substitute the exists,

CodePudding user response:

WITH the AS WITH A together, when A temporary table

CodePudding user response:

refer to 7th floor qiaoyhgaoyan response:
WITH the AS WITH A together, when A temporary table processing

Correct treatment method, construction of temporary table

CodePudding user response:

I would also suggest that can substitute the exists, than in much higher efficiency

CodePudding user response:

refer to the second floor yaiger response:
insert parameters into a temporary table, then associate the temporary table query
if in parameter is introduced to not by querying the other table, how to optimize this problem?

CodePudding user response:

refer to the eighth floor hejingx response:
Quote: refer to 7th floor qiaoyhgaoyan response:

WITH the AS WITH A together, when A temporary table processing

Correct treatment method, construction of temporary table
if in parameter is introduced to not by querying the other table, how to optimize this problem?

CodePudding user response:

refer to 7th floor qiaoyhgaoyan response:
WITH the AS WITH A together, when A temporary table processing
if in parameter is introduced to not by querying the other table, how to optimize this problem?

CodePudding user response:

If the incoming parameters, a lot of, also can be inserted into a temporary table to handle
references to the tenth floor Finn_ response:
Quote: refer to the second floor yaiger response:

Insert the parameters into the temporary table, then associate the temporary table query
if in parameter is introduced to not by querying the other table, how to optimize this problem?

CodePudding user response:

With the exists and the not exists

CodePudding user response:

Try this, for example, the range is 0 to 9999, the following where writing:
Where regexp_like (column_name, '[0-9] [0-9] [0-9] [0-9]')

CodePudding user response:

The conditions of the value type, like this can conditions create indexes, try between... and.. Or use temporary table + exists the query