Add descending index support #6459

Closed
opened 2026-01-22 15:33:34 +01:00 by admin · 8 comments
Owner

Originally created by @fmonts on GitHub (May 2, 2020).

Feature Request

Q A
New Feature yes
RFC no
BC Break no

Summary

Currently, there is no way to create a descending index (with the DESC attribute).
This feature is present in MySQL, MSSQL, PostgreSQL, and probably in the other platforms as well.
(In MySQL older than 8.0 and MariaDB it's accepted but ignored)

It should be allowed a way to create ASC/DESC indexes, for example with:

@ORM\Index(name="my_idx", columns={"col"}, options={"DESC"}),

Or

@ORM\Index(name="my_idx", columns={"col DESC"},
Originally created by @fmonts on GitHub (May 2, 2020). ### Feature Request | Q | A |------------ | ------ | New Feature | yes | RFC | no | BC Break | no #### Summary Currently, there is no way to create a descending index (with the DESC attribute). This feature is present in MySQL, MSSQL, PostgreSQL, and probably in the other platforms as well. (In MySQL older than 8.0 and MariaDB it's accepted but ignored) It should be allowed a way to create ASC/DESC indexes, for example with: @ORM\Index(name="my_idx", columns={"col"}, options={"DESC"}), Or @ORM\Index(name="my_idx", columns={"col DESC"},
admin closed this issue 2026-01-22 15:33:35 +01:00
Author
Owner

@fmonts commented on GitHub (May 2, 2020):

Workaround: you can manually edit the table or add "DESC" in your migration query and luckily the schema generation tool doesn't revert it to ASC when you run it again

@fmonts commented on GitHub (May 2, 2020): Workaround: you can manually edit the table or add "DESC" in your migration query and luckily the schema generation tool doesn't revert it to ASC when you run it again
Author
Owner

@beberlei commented on GitHub (Jul 5, 2020):

We cant support everything in SchemaTool, your workaround is the way to go.

@beberlei commented on GitHub (Jul 5, 2020): We cant support everything in SchemaTool, your workaround is the way to go.
Author
Owner

@24HOURSMEDIA commented on GitHub (Jun 27, 2023):

I disagree with 'We cant support everything in SchemaTool', the descending index is a standard mysql 8, aurora, etc feature
and we absolutely need it on very large tables.

So then the schema created by doctrine is not complete without migrations.

@24HOURSMEDIA commented on GitHub (Jun 27, 2023): I disagree with 'We cant support everything in SchemaTool', the descending index is a standard mysql 8, aurora, etc feature and we absolutely need it on very large tables. So then the schema created by doctrine is not complete without migrations.
Author
Owner

@derrabus commented on GitHub (Jun 27, 2023):

I disagree with 'We cant support everything in SchemaTool'

You're disagreeing with a fact here. 🤷🏻

the descending index is a standard mysql 8, aurora, etc feature

You're right, there's broad support among database vendors for the ASC/DESC keywords in CREATE INDEX.

we absolutely need it on very large tables

If you want to work on a PR, please feel encouraged to do so. First of all, the DBAL library needs to be able to create and introspect this kind of indexes. If you need help with that, feel free to open an issue or draft PR there.

@derrabus commented on GitHub (Jun 27, 2023): > I disagree with 'We cant support everything in SchemaTool' You're disagreeing with a fact here. 🤷🏻 > the descending index is a standard mysql 8, aurora, etc feature You're right, there's broad support among database vendors for the `ASC`/`DESC` keywords in `CREATE INDEX`. > we absolutely need it on very large tables If you want to work on a PR, please feel encouraged to do so. First of all, [the DBAL library](https://github.com/doctrine/dbal/) needs to be able to create and introspect this kind of indexes. If you need help with that, feel free to open an issue or draft PR there.
Author
Owner

@24HOURSMEDIA commented on GitHub (Jun 28, 2023):

Interesting thought to help improve doctrine in this respect.
However my job for this case is primarily devops engineer and keeping our databases affordable and stable.

I doubt my client wants to spend resources on maintaining 3rd party libraries.
I might pick it up if I have spare time some time.

Then I'd be enlisted as a doctrine contributor ? :)

@24HOURSMEDIA commented on GitHub (Jun 28, 2023): Interesting thought to help improve doctrine in this respect. However my job for this case is primarily devops engineer and keeping our databases affordable and stable. I doubt my client wants to spend resources on maintaining 3rd party libraries. I might pick it up if I have spare time some time. Then I'd be enlisted as a doctrine contributor ? :)
Author
Owner

@devbranch-vitaliy commented on GitHub (Jun 12, 2025):

Completely agree with @24HOURSMEDIA, @beberlei closed the ticket without a valid reason.
Since we have the Index attribute/annotation, it must handle the possible option that the DB supports.

It's ridiculous, where oprion is supported, but a simple ASC/DESC is not 🤡

My opinion is that the issue must be reopened.

@devbranch-vitaliy commented on GitHub (Jun 12, 2025): Completely agree with @24HOURSMEDIA, @beberlei closed the ticket without a valid reason. Since we have the Index attribute/annotation, it must handle the possible option that the DB supports. It's ridiculous, `where` oprion is supported, but a simple ASC/DESC is not 🤡 My opinion is that the issue must be reopened.
Author
Owner

@EdouardCourty commented on GitHub (Jul 22, 2025):

Hi, I strongly agree with @devbranch-vitaliy, every index feature should be supported.
Please reopen this issue!

@EdouardCourty commented on GitHub (Jul 22, 2025): Hi, I strongly agree with @devbranch-vitaliy, every index feature should be supported. Please reopen this issue!
Author
Owner

@colesnic89 commented on GitHub (Jan 3, 2026):

Feature Request

Q A
New Feature yes
RFC no
BC Break no

Summary

Currently, there is no way to create a descending index (with the DESC attribute). This feature is present in MySQL, MSSQL, PostgreSQL, and probably in the other platforms as well. (In MySQL older than 8.0 and MariaDB it's accepted but ignored)

It should be allowed a way to create ASC/DESC indexes, for example with:

@ORM\Index(name="my_idx", columns={"col"}, options={"DESC"}),

Or

@ORM\Index(name="my_idx", columns={"col DESC"},

or like this

#[ORM\Index(fields: ['ownerNumber', 'updatedAt' => 'DESC', 'id' => 'DESC'])]

@colesnic89 commented on GitHub (Jan 3, 2026): > ### Feature Request > Q A > New Feature yes > RFC no > BC Break no > #### Summary > Currently, there is no way to create a descending index (with the DESC attribute). This feature is present in MySQL, MSSQL, PostgreSQL, and probably in the other platforms as well. (In MySQL older than 8.0 and MariaDB it's accepted but ignored) > > It should be allowed a way to create ASC/DESC indexes, for example with: > > ``` > @ORM\Index(name="my_idx", columns={"col"}, options={"DESC"}), > ``` > > Or > > ``` > @ORM\Index(name="my_idx", columns={"col DESC"}, > ``` or like this `#[ORM\Index(fields: ['ownerNumber', 'updatedAt' => 'DESC', 'id' => 'DESC'])]`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6459