-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
Client unable to query entry number 1 in the API #3954
Comments
Here are the two queries that are run when you do this request:
|
And here's the EXPLAIN:
That's for the count. I imagine there'd be a third query if we had some content in here. Note that we're doing a
So that index didn't do what I'd hoped. On the other hand, it occurs to me that we might not have updated the stats on this DB since it was created from a replica. Maybe we need to do that. |
OK, currently running
|
Lame, no change. But I've updated the replication docs to run Not sure of next steps. Probably need to either:
|
@ERosendo or @albertisfu do you have suggestions for next steps here? Trying to think if this is even something we can solve. |
yeah, this one seems complicated. Perhaps we can try applying a composite index that includes the
Since the query uses both fields to retrieve the docket entries: |
Great point. I'll give that a try. |
OK, new index in place, and...
So...no change. |
Got it. It's strange that the planner is not using the index, which seems to be due to how the query is structured. I did try the following query:
Which uses a With this query the composited index is being used:
However, note that the index that worked is the one without the constraint |
@albertisfu did you run that test in the dev db? or in your local db? |
I tested it on my local database, so it is not representative in terms of the number of records. |
@albertisfu thanks for clarifying! In this scenario, the serializer class generates the queries, limiting our control over SQL specificity. We can consider exploring alternative approaches if we need finer control in the future. I'm still hoping a VACUUM can resolve the issue. |
Well, I ran
Which is a lot better. Running it with an So vacuuming really seemed to help or the new index + the vacuum helped. I have always assumed that tweaking vacuums by hand wasn't necessary. I guess it's time to start doing that. |
And just for completeness, I removed the index and tried the query again. It took 186s:
|
Cool, so I think the way forward here is:
|
OK, so this worked fine in prod after creating the index. I think that means we should run |
They're doing a pretty straightforward API request (don't click this, it's timing out):
https://www.courtlistener.com/api/rest/v3/docket-entries/?entry_number=1&docket__court=nysd
Either it's sad because of the join (I hope not) or because of the filter on the entry number. I think it's the latter because that field doesn't have an index on it.
A simple solution would be to add an index on the field:
But I can't think of a reason why anybody would ever look up an entry other than #1, as above, so I'm thinking we could save some DB memory with:
But then the cardinality of the index gets really small, making me wonder if it would do us much good! I admit I'm outside my zone of comfort.
Next step:
If performance is fixed by the index with the very narrow
condition
, great, we're off to the races.The text was updated successfully, but these errors were encountered: