# Why is Cakephp calling SQL queries for information\_scheme?

**URL:** <https://discourse.cakephp.org/t/why-is-cakephp-calling-sql-queries-for-information-scheme/3579>\
**Category:** Need Help\
**Created:** [November 26, 2017, 10:00pm UTC](https://discourse.cakephp.org/t/why-is-cakephp-calling-sql-queries-for-information-scheme/3579 "2017-11-26T22:00:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cakeuser](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@cakeuser](https://discourse.cakephp.org/u/cakeuser)\
**Post date:** [November 26, 2017, 10:00pm UTC](https://discourse.cakephp.org/t/why-is-cakephp-calling-sql-queries-for-information-scheme/3579/1 "2017-11-26T22:00:50Z")

</div>

I’m using Cakephp 3.3 and DebugKit is enabled. I have noticed that ‘some’ of the controller actions are issuing many additional SQL queries related to information\_scheme like these:

SHOW FULL COLUMNS  
FROM  
`businesses`

SHOW INDEXES  
FROM  
`businesses`

SELECT  
\*  
FROM  
information\_schema.key\_column\_usage AS kcu  
INNER JOIN information\_schema.referential\_constraints AS rc ON (  
kcu.CONSTRAINT\_NAME = rc.CONSTRAINT\_NAME  
AND kcu.CONSTRAINT\_SCHEMA = rc.CONSTRAINT\_SCHEMA  
)  
WHERE  
kcu.TABLE\_SCHEMA = 'myschema’  
AND kcu.TABLE\_NAME = 'businesses’  
AND rc.TABLE\_NAME = ‘businesses’

Questions:

1. Why is this happening ?
2. Is this there a way to stop Cakephp from doing this ?
3. Is it happening because of DebugKit ?

---

<div class="post-metadata">

**Author:** ![jarekgol](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jarekgol](https://discourse.cakephp.org/u/jarekgol)\
**Post date:** [November 26, 2017, 10:55pm UTC](https://discourse.cakephp.org/t/why-is-cakephp-calling-sql-queries-for-information-scheme/3579/2 "2017-11-26T22:55:19Z")

</div>

There is a benefit from it - if you add some columns to your SQL table, then they automatic show in your php variable.

---

<div class="post-metadata">

**Author:** ![cakeuser](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@cakeuser](https://discourse.cakephp.org/u/cakeuser)\
**Post date:** [November 26, 2017, 11:51pm UTC](https://discourse.cakephp.org/t/why-is-cakephp-calling-sql-queries-for-information-scheme/3579/3 "2017-11-26T23:51:55Z")

</div>

How to prevent it ? And does it have anything to do with DebugKit ?

---

<div class="post-metadata">

**Author:** ![jarekgol](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jarekgol](https://discourse.cakephp.org/u/jarekgol)\
**Post date:** [November 27, 2017, 8:29pm UTC](https://discourse.cakephp.org/t/why-is-cakephp-calling-sql-queries-for-information-scheme/3579/4 "2017-11-27T20:29:47Z")

</div>

I saw this when debug kit is on, but never try to check what happens in "production: it never disturbs me. You can set some sql log options in config turn debug to false and check.  
But I know that if you add some column in production mode, then before clear cache it can miss them, so I guess that in “production” there will be no schema check.

---

<div class="post-metadata">

**Author:** ![markstory](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/markstory/32/182_2.png) [@markstory](https://discourse.cakephp.org/u/markstory)\
**Post date:** [December 3, 2017, 3:57am UTC](https://discourse.cakephp.org/t/why-is-cakephp-calling-sql-queries-for-information-scheme/3579/5 "2017-12-03T03:57:35Z")

</div>

Correct. In production mode, cache duration for the schema meta data is much higher by default. This metadata cache holds the results of the `information_schema` queries, and allows CakePHP to operate without emitting these queries.
