mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Redundant index created when FK column part of composite index #5744
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @stevepetcu on GitHub (Oct 19, 2017).
Hey,
Besides a post on Google Forms from a few years ago, I haven't found anything on this.
Say you create a composite index, like this, on a table:
, where
country_codehappens to also be a FK.I'm working with MySQL, by the way. From what I understand, this index should satisfy its FK indexing requirements (the
country_codeis the first field in the composite index). However, Doctrine generates the following query:Is this expected behaviour and I'm missing something, or is this something that can be improved?
@Ocramius commented on GitHub (Oct 19, 2017):
I think this was fixed for single column identifiers, but not for multi-column ones. Can you try and see if the issue persists on
master?@stevepetcu commented on GitHub (Oct 19, 2017):
I'm getting an identical result with the
dev-masterversion for my schema creation SQL.And yes, when it comes to single-column indexes, I can specify them myself and Doctrine will only generate those ones (useful for having some nice index names). :)
@mateuszsip commented on GitHub (Oct 23, 2017):
Looks like this is cause of your problems.
A simple test case:
confirms that it doesn't work.
I can try to do something about it, but could need some help.
@stevepetcu commented on GitHub (Oct 23, 2017):
There is a typo in the
isFullfilledBymethod name and it's a public method written in 2010. Nooooo!@kejwmen nice, I'm taking a look at it, see if I figure out how it works. 👍
@stevepetcu commented on GitHub (Oct 23, 2017):
I made a PR with a fix for this: https://github.com/doctrine/dbal/pull/2895
I'm not sure whether I'm supposed to make it against the
develop, or themaster, but I had a bunch of failing tests on thedevelop, so I made it against the master. :)@Ocramius I also don't know is this is the place to ask for a code review, but please let me know if I should change anything.
@Ocramius commented on GitHub (Oct 23, 2017):
Seen the patch, won't get to do proper githubbing for a while though, as
I'm always at the computer only for "paid work" these days 🤐
On 23 Oct 2017 13:47, "Stefan" notifications@github.com wrote:
@stevepetcu commented on GitHub (Oct 23, 2017):
Heh, I know all about that. I'm in-between jobs at the moment, so I have some free time.
I saw there were some failed tests. I only ran the ones under the
DBAL/Schemalocally, as there was a large number of skipped tests and some that were failing due to missing drivers on the whole, but I'll have to check what's failing more carefully, probably tomorrow. I think there are some fails due to missing drivers on the CI, too, is that normal?@stevepetcu commented on GitHub (Oct 23, 2017):
By the way, I ran a schema update sql dump on my app. It will remove 4 redundant indexes. That's pretty significant, as I only have 9 entities at the moment.
I also ran a schema create and it looks OK.