Problem/Motivation
Using the "information_schema" tables in PostgreSQL is very slow. @Mixologic who works for the Drupal Association has pointed out in #2847855-19: Incorrect statement class caused by race condition when closing and opening the connection.
PostgreSQL uses the default implementation for the method Schema::fieldExists(). And the default implementation uses the "information_schema" tables.
Proposed resolution
To speed PostgreSQL up it would be the best to create a specific PostgreSQL implementation of Schema::fieldexists().
Remaining tasks
- Do research (Mixologic) - DONE
- Write a patch (daffie) - DONE
- Review patch
- Performance review
User interface changes
None
API changes
Table field exists information is gathered in a different way with potentially some differences for PostgreSQL. This does not seem to have any affect on tests.
Data model changes
None.
For the committer
Can Mixologic also get commit credits for being the one that came with the problem.
Comment | File | Size | Author |
---|---|---|---|
#7 | drupal-2850684-7.patch | 911 bytes | RoSk0 |
#3 | 2850684-3.patch | 1.2 KB | daffie |
Comments
Comment #2
daffie CreditAttribution: daffie commentedComment #3
daffie CreditAttribution: daffie commented:schema.:table
will become'public'.'node'
and not what we need it to be like:'public.node'
.Comment #4
daffie CreditAttribution: daffie commentedThe testbot finishes with this patch a lot faster:
Comment #5
daffie CreditAttribution: daffie commentedThe method Schema::findTables() has the same problem as Schema::fieldExists(), it uses the "information_schema" tables. The method Schema::findTables is only used twice in the test Drupal\KernelTests\Core\Database\SchemaTest. Does anybody have any idea how much this method is used in contrib modules and third party modules. Shall we do the same for Schema::findTables or does nobody uses the method.
Comment #7
RoSk0Re-rolled #3.
Lets take a look is it still adding that much in performance terms.
Comment #8
RoSk011 minutes comparing to https://dispatcher.drupalci.org/job/drupal_patches/36889/. That's pretty awesome!
I will be bold
Comment #9
daffie CreditAttribution: daffie commented+1 for RTBC
Comment #10
mradcliffeYeah, this patch looks like a good improvement. Awesome.
Comment #11
alexpottThere should be a followup to discuss #5 and the
Schema::findTables()
method.Comment #12
daffie CreditAttribution: daffie commentedCreated the followup: #2921855: Default Database Schema::findTables() is slow for PostgreSQL.
Comment #13
alexpottLooks like we have a reliable segmentation fault on PHP5.5 andPostgres :( https://www.drupal.org/pift-ci-job/805466
Comment #14
alexpottCreated #2921862: Segfault on PHP5.5 and PostgreSQL
Comment #15
mradcliffeYeah.
I saw it earlier, and re-ran the test, but it's reliably seg faulting. :(
Looks like an OOM error during PHP shutdown or garbage collection? I tried looking in the PHP stack trace where fieldExists could be getting called that, but that turned into a bigger rabbit hole than I expected for the time I could put into it. It might not be in the stack trace at all, but a side effect of some other query.
It's probably happening in setUp because that's the most db intensive thing with regard to schema changes.
Comment #17
catch8.5.x is back to green with postgres and successfully retested this patch.
Committed f73e805 and pushed to 8.5.x. Thanks!