Comments (6)
Can you try to run the query with WHERE "userId" = $3 AND "read" IS FALSE
?
from peertube.
It doesn't seem to affect the cost:
peertube_prod=# EXPLAIN UPDATE "userNotification" SET "read"=true,"updatedAt"='2024-05-03 17:03:28.649+00' WHERE "userId" = 1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------
Update on "userNotification" (cost=1112.06..52909.66 rows=35049 width=75)
-> Bitmap Heap Scan on "userNotification" (cost=1112.06..52909.66 rows=35049 width=75)
Recheck Cond: ("userId" = 1)
-> Bitmap Index Scan on user_notification_user_id (cost=0.00..1103.30 rows=35049 width=0)
Index Cond: ("userId" = 1)
(5 rows)
peertube_prod=# EXPLAIN UPDATE "userNotification" SET "read"=true,"updatedAt"='2024-05-03 17:03:28.649+00' WHERE "userId" = 1 AND read IS FALSE;
QUERY PLAN
-----------------------------------------------------------------------------------------------------
Update on "userNotification" (cost=1111.05..52908.65 rows=30990 width=75)
-> Bitmap Heap Scan on "userNotification" (cost=1111.05..52908.65 rows=30990 width=75)
Recheck Cond: ("userId" = 1)
Filter: (read IS FALSE)
-> Bitmap Index Scan on user_notification_user_id (cost=0.00..1103.30 rows=35049 width=0)
Index Cond: ("userId" = 1)
(6 rows)
from peertube.
It doesn't seem to affect the cost:
Can you try to just test the query? I think most of time is spent Updating rows and not finding them.
from peertube.
I ran with EXPLAIN ANALYZE and the difference in execution time is huge:
peertube_prod=# EXPLAIN ANALYZE UPDATE "userNotification" SET "read"=true,"updatedAt"='2024-05-03 17:03:28.649+00' WHERE "userId" = 1 AND read IS FALSE;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------
Update on "userNotification" (cost=1123.22..53718.19 rows=31466 width=75) (actual time=86.252..86.254 rows=0 loops=1)
-> Bitmap Heap Scan on "userNotification" (cost=1123.22..53718.19 rows=31466 width=75) (actual time=86.250..86.251 rows=0 loops=1)
Recheck Cond: ("userId" = 1)
Filter: (read IS FALSE)
Rows Removed by Filter: 31382
Heap Blocks: exact=6925
-> Bitmap Index Scan on user_notification_user_id (cost=0.00..1115.35 rows=35589 width=0) (actual time=12.815..12.815 rows=74747 loops=1)
Index Cond: ("userId" = 1)
Planning Time: 0.221 ms
Execution Time: 86.434 ms
(10 rows)
peertube_prod=# EXPLAIN ANALYZE UPDATE "userNotification" SET "read"=true,"updatedAt"='2024-05-03 17:03:28.649+00' WHERE "userId" = 1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------
Update on "userNotification" (cost=1124.25..53719.22 rows=35589 width=75) (actual time=1360.231..1360.232 rows=0 loops=1)
-> Bitmap Heap Scan on "userNotification" (cost=1124.25..53719.22 rows=35589 width=75) (actual time=12.338..88.100 rows=31382 loops=1)
Recheck Cond: ("userId" = 1)
Heap Blocks: exact=6925
-> Bitmap Index Scan on user_notification_user_id (cost=0.00..1115.35 rows=35589 width=0) (actual time=11.143..11.143 rows=74747 loops=1)
Index Cond: ("userId" = 1)
Planning Time: 0.166 ms
Execution Time: 1360.387 ms
(8 rows)
Adding AND "read" IS FALSE
looks like a success.
from peertube.
Thanks! Changed in 9ee1f7b
from peertube.
Thanks! For me it's okay to close this issue since the root issue has been solved.
from peertube.
Related Issues (20)
- Error on FreeBSD when following instructions on diffing configuration changes HOT 1
- Server crashes with "Error: write EPIPE" HOT 4
- Possibility to increase maxAttempts for s3 uploads
- Peertube won't start: "permission denied for schema public" HOT 1
- Question mark "?" in front of user email in webadmin HOT 5
- OAuth 2FA in Documentation HOT 1
- Dereference error type field in REST API documentation HOT 1
- All transcoding jobs result in an error: Output format mp4 is not available HOT 5
- Peertube doesn't display channels HOT 1
- Declarative plugin management HOT 1
- The configuration file issue after upgraded to v6.0.4 HOT 1
- View count for short videos HOT 13
- Error while exporting user account(s). HOT 2
- Email verified when set by external auth providers
- Video admin overview: missing filter for video with original files
- (please delete) HOT 1
- Can't follow channels on multiple servers from Mastodon. HOT 9
- Can't find plugin dependencies HOT 2
- Older videos show "Failed to play video" HOT 5
- Significant Audio Desync on Chromium and Webkit-based Browsers HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from peertube.