Custom Sorting Issue

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 自定义排序问题

| username: Lowerui

For a data table with approximately 1 billion rows, where fl is an indexed field and you need to perform an IN query with 10,000 entries, and sort according to the input order of the field field, what optimization solutions are available?

SELECT fl, name FROM t WHERE fl in (1, 2, 3) ORDER BY FIELD(fl, 1, 2, 3)
| username: xfworld | Original post link

In 10,000 queries, change to temporary tables for Join.

For sorting, it’s best to use other methods instead (sorting will aggregate data to TiDB, which can easily cause OOM).

Try to partition the range as much as possible.

| username: 近墨者zyl | Original post link

I don’t understand this SQL… What does the part after “order by” mean?

| username: alfred | Original post link

When sorting, consider pushing operators down to the storage layer or using operators that consume less memory.

| username: alfred | Original post link

| username: Lowerui | Original post link

Custom sorting, sort according to the values inside “in”.

| username: forever | Original post link

Isn’t it better for the program to fetch and display each item in a loop directly?

| username: 胡杨树旁 | Original post link

For sorting, isn’t it that each TiKV node performs the sorting first and then aggregates it to TiDB for sorting?

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.