There is a table in which the search always takes place in two columns - origin and destination . The values of the columns are a three-digit string - MOW , LED , etc. The table stores about 50,000 records and requests for it are executed for 2 seconds. To speed up the queries came up with the following algorithm:
- Create a new column called
key. Write the values from theoriginanddestinationfields into it, separating them with a dash. It turns out the record typeMOW-LED, which will always be unique. - Create a unique index (
CREATE UNIQUE INDEX) for the table by the value of the newly createdkeycolumn
How can this be done with a single SQL query?
UNIQUE), which will give another plus to an exact search .... - Vladimir Klykov