-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
qids optimization on /wiki/tag/method ? #8242
Comments
Hey @jywarren Sure, I will look into this 👍 |
Hey @jywarren @cesswairimu @sagarpreet-chadha I went through the issue and initially I didn't exactly understand why we had this specific way of querying here but now after some inspection I figured its because the definition of question in our models is not defined and it represents all notes having atleast one question: tag which should be more suited by all notes having question: tags for all normal tags present. So we need to query from the nodes all the nodes which have at least one tag with
Thanks ✌️ |
Hey @Tlazypanda , |
@Tlazypanda thank you for going through this investigation, i wanted to ask if a plain |
Hey @ebarry according to the code for fetching the questions we match it against all nodes having atleast one tag starting with |
Hi, just noting this again as a good one to optimize. I think we can instead of using plots2/app/controllers/tag_controller.rb Lines 131 to 139 in 92834ea
Here's how we should do it: Lines 948 to 951 in cbb807b
|
So it might be like: if @node_type == 'note'
@notes = nodes
.joins(:tag)
.where('term_data.name LIKE ?', 'question:%') # here i'm not sure -- we need to /exclude/ questions... so...
.group('node.nid')
elsif @node_type == 'questions'
@questions = nodes
.joins(:tag)
.where('term_data.name LIKE ?', 'question:%')
.group('node.nid')
end The tough part here is the query for notes that excludes questions. We may need a custom query, something like this??? https://stackoverflow.com/a/711671 SELECT apps.ApplicationName, apps.isavailable
FROM dbo.Applications apps
WHERE apps.ApplicationName = @AppName
AND NOT EXISTS
( SELECT *
FROM Holidays
WHERE ApplicationId = apps.ApplicationId
AND CONVERT(VARCHAR,getdate(),101) = CONVERT(VARCHAR,holidaydate,101)
) It may need some experimentation to get this right!!! |
I think this is our top target for optimization now! It affects all tag pages, i believe. |
Hi! Can I look into this? |
@anirudhprabhakaran3 yeah go ahead!! |
Hi @Tlazypanda -- i found this line which results in a query for 1600 records in our production db, for pages like https://publiclab.org/wiki/tag/method
plots2/app/controllers/tag_controller.rb
Lines 131 to 139 in 92834ea
I think it's worth hunting through the blame history to see what this is all about: https://github.com/publiclab/plots2/blame/92834ead6c53d6d9431bb99024d4044b282518be/app/controllers/tag_controller.rb#L131-L139
I think there must be a better way to do it, and/or a way to cache it. I think what it's trying to do is to filter out questions (a node of
type = 'note'
but with a tag starting withquestion:_____
) from the results. But it's a big query and will only get larger as the db grows. Surely we can fix this!What do you think? How does it look on Skylight?
The text was updated successfully, but these errors were encountered: