Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: keep file order #8659

Merged
merged 1 commit into from
May 14, 2022
Merged

fix: keep file order #8659

merged 1 commit into from
May 14, 2022

Conversation

Johann150
Copy link
Contributor

What

The file IDs are used in the order they are sent.

When using the IN operator, the database will return the files in the order they are stored on disk, which is usually the order they were inserted in. That explains why attachments were always ordered by file ID as noted in the issue.

To keep the advantage of having a single database query, I modified the query to add an order by clause instead of partly reverting 9f7cdb4 which would have meant multiple queries. This should keep any improved performance.

Why

fix #8647

@Johann150 Johann150 requested a review from syuilo May 13, 2022 08:44
@syuilo syuilo merged commit 4b87285 into misskey-dev:develop May 14, 2022
@syuilo
Copy link
Member

syuilo commented May 14, 2022

👍🏻👍🏻👍🏻

@tamaina
Copy link
Member

tamaina commented May 14, 2022

function array_position(text[], character varying) does not exist が出た

@Johann150
Copy link
Contributor Author

Johann150 commented May 14, 2022 via email

@absturztau-be
Copy link

same happened to me. resulted into not being able to post notes with attachments and it slowed down drive too

psql version 13.5 for me

according to the psql docs, it should be part of it too

https://www.postgresql.org/docs/13/functions-array.html

Can you try if it works if you cast the id to the same type with "id"::text?

haven't tested this yet

@absturztau-be
Copy link

changing the query to array_position(ARRAY[<whatever>], "id"::text) seems to work on psql 13.5

@tamaina
Copy link
Member

tamaina commented May 15, 2022

I use 13.7.

@Johann150 Which version are you using?

Can you try if it works if you cast the id to the same type with "id"::text?

haven't tested this yet

@Johann150
Copy link
Contributor Author

Ah, my testing environment used Postgres 14.2, so I was using the wrong version of Postgres. My mistake 🙇

Johann150 added a commit that referenced this pull request May 15, 2022
Fix a bug introduced in #8659. Solution was already tested there.
@Johann150 Johann150 deleted the fix-file-order branch May 15, 2022 10:04
@Johann150
Copy link
Contributor Author

Thanks for catching this, has been fixed on develop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

添付した画像の順番がドライブに上げた順になる
4 participants