N
N
nerabio2017-09-18 14:05:35
Yii
nerabio, 2017-09-18 14:05:35

How to solve Yii2 Active Record slow meta query issue?

Good afternoon,
Please tell me how to solve the problem. There is a SQL Server database for CRM on it, when working with this database, queries last indecently long (on other databases it works quickly). The built-in debugger shows that a query that receives FK keys and column names takes 4 seconds, this is only for one table. Running this query through Management Studio, the execution time is the same. Is it possible in Yii2 to disable validation of this particular key association? Or how to get out of this situation?
The request itself.
SELECT
[rc].[constraint_name] AS [fk_name],
[kcu1].[column_name] AS [fk_column_name],
[kcu2].[table_name] AS [uq_table_name],
[kcu2].[column_name] AS [uq_column_name]
FROM [ INFORMATION_SCHEMA].[REFERENTIAL_CONSTRAINTS] AS [rc]
JOIN [INFORMATION_SCHEMA].[KEY_COLUMN_USAGE] AS [kcu1] ON
[kcu1].[constraint_catalog] = [rc].[constraint_catalog] AND
[kcu1].[constraint_schema] = [rc].[constraint_schema] AND
[kcu1].[ constraint_name] = [rc].[constraint_name]
JOIN [INFORMATION_SCHEMA].[KEY_COLUMN_USAGE] AS [kcu2] ON
[kcu2].[constraint_catalog] = [rc].[constraint_catalog] AND
[kcu2].[constraint_schema] = [rc] .[constraint_schema] AND
[kcu2].[constraint_name] = [rc].[unique_constraint_name] AND
[kcu2].[ordinal_position] = [kcu1].[ordinal_position]
WHERE [kcu1].[table_name] = 'Account' AND [ kcu1].[table_schema] = 'dbo'
ae8dda9710864a7ba125f57abab0fff7.jpg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya Beloborodov, 2017-09-18
@nerabio

In the database config , you can also set the time . Usually they put it on the sale. All meta requests will be cached

Y
yiiworld, 2017-12-01
@yiiworld

- caching is certainly good, but 4 seconds does not cancel it
- it seems that your INFORMATION_SCHEMA does not have enough indexes (or there is a problem with them)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question