doctrine / dbal

Doctrine Database Abstraction Layer
https://www.doctrine-project.org/projects/dbal.html
MIT License
9.44k stars 1.33k forks source link

Allow to exclude system/non-user tables #5764

Open mvorisek opened 1 year ago

mvorisek commented 1 year ago

Feature Request

this is a result of investigation of https://github.com/doctrine/dbal/issues/5698

Q A
New Feature yes
RFC no

Summary

in atk4/data we are excluding Oracle system tables by extending the OraclePlatform::getListTablesSQL method

https://github.com/atk4/data/blob/0c6bce5c2ac53589934b02bc0832a4753c283f15/src/Persistence/Sql/Oracle/PlatformTrait.php#L111-L119

we do so to massively improve the discovery performance as listing the system/non-user table is not helpful

in DBAL 3.3 this reduced the tests time from hours to about 2 minutes

in DBAL 3.4.x https://github.com/doctrine/dbal/pull/5268 was introuced, which reduced the time, without the custom OraclePlatform::getListTablesSQL method override described above, to about 8 minutes

this is a feature request to filter the oracle_maintained tables (and objects in general) out by default and/or to provide an option in schema manager to enable/disable such filtering

mvorisek commented 1 year ago

if no official customization of schema manager is wanted, I would be happy with a protected method in OracleSchemaManager::getListTablesSQL() (or in OraclePlatform::getListTablesSQL() as before) which will be inserted as a subquery in all queries where all tables are used

morozov commented 1 year ago

Filtering out oracle_maintained tables by default sounds reasonable. But how does schema management work now if they don't get filtered out?

In general, the DBAL introspects the schema for the purpose of managing it, so the tables that it cannot manage should be ignored.

mvorisek commented 1 year ago

in atk4/data we use the system user which has global permissions granted

https://github.com/atk4/data/blob/c30e90879bbf21ec946d648ee112d32b90edc9fd/.github/workflows/test-unit.yml#L238-L242

and then the tables are visible

looking into DBAL CI https://github.com/doctrine/dbal/blob/3.4.x/.github/workflows/continuous-integration.yml it seems this is also what DBAL CI does

But how does schema management work now if they don't get filtered out?

so it seems DBAL CI either creates some non-system user somewhere before running the tests or actually lists all tables (incl. the oracle_maintained) - is there any tests asserting there are no tables in CI database?


please also remove the block for my user, currently, I do not receive any notifications, no notificantions about your commnets, closes, ... which leads to https://github.com/doctrine/dbal/issues/5698#issuecomment-1264695592 :(

morozov commented 1 year ago

is there any tests asserting there are no tables in CI database?

Most likely, no. Such a test would fail if run as part of the test suite because most of the tests clean up before themselves but not after.