Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3k stars 880 forks source link

[Bug] Large increase in amount of executed queries #5516

Closed jnoordsij closed 2 months ago

jnoordsij commented 2 months ago

Bug report

What I did

In my recent Sentry reports, I found several N+1 query issue reports on various different admin panel pages. Looking into them, I noticed that on basically all pages visited, for each table available in my database, there are two queries being fired (regardless of page content):

select column_name as `name`, data_type as `type_name`, column_type as `type`,
                      collation_name as `collation`, is_nullable as `nullable`,
                                        column_default as `default`, column_comment as `comment`,
                                        generation_expression as `expression`, extra as `extra`
from information_schema.columns
where table_schema = 'FOO'
  and table_name = 'BAR'
order by ordinal_position asc
select index_name as `name`, group_concat(column_name order by seq_in_index) as `columns`,
       index_type as `type`, not non_unique as `unique`
from information_schema.statistics
where table_schema = 'FOO'
  and table_name = 'BAR'
group by index_name, index_type, non_unique

What I expected to happen

No obsolete queries being fired.

What happened

A lot of queries fetching data that seems largely obsolete.

What I've already tried to fix it

My observations and thoughts:

Given that I'm not immediately sure about the moving parts involved, I've decided to stick with reporting this for now. If more info/help is needed, let me know, then I'll happily assist in tracking down the source of this issue.

Is it a bug in the latest version of Backpack?

Yes

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

### PHP VERSION:
8.3.6

### PHP EXTENSIONS:
Core, bcmath, calendar, ctype, date, filter, hash, iconv, json, SPL, pcre, random, readline, Reflection, session, standard, mysqlnd, tokenizer, zlib, libxml, dom, PDO, openssl, SimpleXML, xml, xmlreader, xmlwriter, curl, FFI, ftp, fileinfo, gd, gmp, intl, mbstring, exif
, mysqli, Phar, pdo_mysql, pdo_sqlite, xsl, zip, xdebug, Zend OPcache

### LARAVEL VERSION:
11.3.1.0

### BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.3.1
backpack/crud: 6.7.11
backpack/filemanager: 3.0.7
backpack/pro: 2.1.12
backpack/theme-tabler: 1.2.8

Further info: running this on MySQL databases, both 8.0.x and 8.4.0.

pxpm commented 2 months ago

Hey @jnoordsij thanks for the heads up. 🙏

I am already working on the fix for that here: https://github.com/Laravel-Backpack/CRUD/pull/5504

I will bump that PR priority.

Cheers

jnoordsij commented 2 months ago

Fixed by #5504.