Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separated scheme loading from main thread. #122

Open
kamarton opened this issue Mar 7, 2020 · 4 comments
Open

Separated scheme loading from main thread. #122

kamarton opened this issue Mar 7, 2020 · 4 comments

Comments

@kamarton
Copy link
Contributor

kamarton commented Mar 7, 2020

What steps will reproduce the problem?

Schema loading on the main thread is problematic in several ways (like yii2):

  • block main thread, increase response delay
  • not really suitable for event based updates (for example after deploy)
  • cache TTL problems
    • with large TTL, the change is noticed slowly
    • with small TTL, a lot of updates are unnecessary

What is the expected result?

  • The schema load can be called at any time, regardless of the main thread

I suggests

The best solution would be to generate the table schema to PHP code (for example one class/table).

  • not require cache (no connection and loading delay)
  • generation is event-based (for example, after generating the yii3 configuration)
Q A
Version 3.0.x-dev
PHP version -
Operating system -
@samdark
Copy link
Member

samdark commented Mar 12, 2020

That would potentially hurt ability to adjust table rapidly during development, right?

@kamarton
Copy link
Contributor Author

That would potentially hurt ability to adjust table rapidly during development, right?

Partially. Another problem is that schema requests are executed during the HTTP request, thereby slowing down the HTTP response. This is a problem in yii2: yiisoft/yii2#17444.

Of course, it would also be useful if the changes made to the code or database could be easily checked in all states without having to turn on / off the schema cache in the config:

  • actual code + new database
  • new code + actual database
  • new code + new database

@samdark
Copy link
Member

samdark commented Mar 28, 2020

So the following could be a solution:

  1. Create a console command that can dump schema to a file.
  2. Add ability to use the file instead of getting fresh schema from database.

@Tigrov
Copy link
Member

Tigrov commented Sep 7, 2023

What is the difference of using new SchemaCache(new FileCache(__DIR__ . '/runtime/cache')) in the Connection?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants