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

Consider new DB indices for dashboard performance #449

Open
ahelsing opened this issue Nov 5, 2015 · 0 comments
Open

Consider new DB indices for dashboard performance #449

ahelsing opened this issue Nov 5, 2015 · 0 comments

Comments

@ahelsing
Copy link
Member

ahelsing commented Nov 5, 2015

Consider adding some additional DB indices for performance on the dashboard.

On the dashboard, a few queries look expensive, and indices look like they would help.
However, the overall page load is not slow and the indices seem to only help marginally.
As a result, adding these at the moment is probably not worth doing. But in future if things are slow, these are potential improvements.

  1. Querying a member's role on a slice by member URN and slice URN would be faster given and index on sa_slice(slice_urn, slice_id) as it joins across that table.
    Sample query:
SELECT sa_slice_member.role AS sa_slice_member_role, sa_slice.slice_urn AS sa_slice_slice_urn, ma_member_attribute.id AS ma_member_attribute_id, ma_member_attribute.member_id AS ma_member_attribute_member_id, ma_member_attribute.name AS ma_member_attribute_name, ma_member_attribute.value AS ma_member_attribute_value, ma_member_attribute.self_asserted AS ma_member_attribute_self_asserted
    FROM sa_slice_member, sa_slice, ma_member_attribute
    WHERE sa_slice_member.slice_id = sa_slice.slice_id AND ma_member_attribute.member_id = sa_slice_member.member_id AND sa_slice.slice_urn IN ('urn:publicid:IDN+ch1.gpolab.bbn.com:GPO-Project+slice+ansible') AND ma_member_attribute.name = 'urn' AND ma_member_attribute.value = 'urn:publicid:IDN+ch1.gpolab.bbn.com+user+ahelsing'
  1. Fetching the member URN for a list of member_ids is slow. Adding an index on ma_member_attribute(member_id, name, value) helps a bit. Sample query:
SELECT ma_member_attribute.value AS ma_member_attribute_value, ma_member_attribute.member_id AS ma_member_attribute_member_id
    FROM ma_member_attribute
    WHERE ma_member_attribute.member_id IN ('f4dfc8c6-0b1e-4453-a438-b8ff58fafdae', 'f4dfc8c6-0b1e-4453-a438-b8ff58fafdae', 'f4dfc8c6-0b1e-4453-a438-b8ff58fafdae', 'f4dfc8c6-0b1e-4453-a438-b8ff58fafdae', 'f4dfc8c6-0b1e-4453-a438-b8ff58fafdae', 'd2909ac7-11ff-4206-8fb6-0ef88c6b945b', 'c9c4db82-8b12-4f2e-af68-a7abeb0da5d7', 'd2909ac7-11ff-4206-8fb6-0ef88c6b945b', 'd2909ac7-11ff-4206-8fb6-0ef88c6b945b', 'f4dfc8c6-0b1e-4453-a438-b8ff58fafdae', '41dc9c8e-80a7-44ca-ae3c-8c2ad4fe52b4', 'd2909ac7-11ff-4206-8fb6-0ef88c6b945b', '41dc9c8e-80a7-44ca-ae3c-8c2ad4fe52b4', 'd2909ac7-11ff-4206-8fb6-0ef88c6b945b', '41dc9c8e-80a7-44ca-ae3c-8c2ad4fe52b4', '41dc9c8e-80a7-44ca-ae3c-8c2ad4fe52b4', 'c9c4db82-8b12-4f2e-af68-a7abeb0da5d7', '41dc9c8e-80a7-44ca-ae3c-8c2ad4fe52b4', '41dc9c8e-80a7-44ca-ae3c-8c2ad4fe52b4', '41dc9c8e-80a7-44ca-ae3c-8c2ad4fe52b4', 'c9c4db82-8b12-4f2e-af68-a7abeb0da5d7', 'df275ee5-1029-41f3-ad3a-fbd5758987cb', 'f4dfc8c6-0b1e-4453-a438-b8ff58fafdae', 'd2909ac7-11ff-4206-8fb6-0ef88c6b945b', '1f1b1246-e8f5-4f03-bf72-118d9564a05b') AND ma_member_attribute.name = 'urn'
  1. Getting open join requests by project lead (not project) gets better with an index on pa_project_member_request(requestor, context_id, status). Sample sql:
SELECT pa_project_member_request.status AS pa_project_member_request_status, ma_member_attribute_1.value AS lead_urn, ma_member_attribute_2.value AS requestor_urn
    FROM pa_project_member_request, ma_member_attribute AS ma_member_attribute_1, ma_member_attribute AS ma_member_attribute_2, pa_project_member AS pa_project_member_1
    WHERE pa_project_member_1.member_id = ma_member_attribute_1.member_id AND pa_project_member_request.requestor = ma_member_attribute_2.member_id AND ma_member_attribute_1.name = 'urn' AND ma_member_attribute_2.name = 'urn' AND ma_member_attribute_1.value IN ('urn:publicid:IDN+ch1.gpolab.bbn.com+user+agosain', 'urn:publicid:IDN+ch1.gpolab.bbn.com+user+nriga', 'urn:publicid:IDN+ch1.gpolab.bbn.com+user+ahelsing', 'urn:publicid:IDN+ch1.gpolab.bbn.com+user+hdempsey', 'urn:publicid:IDN+ch1.gpolab.bbn.com+user+tmitchel', 'urn:publicid:IDN+ch1.gpolab.bbn.com+user+sedwards', 'urn:publicid:IDN+ch1.gpolab.bbn.com+user+mbrinn') AND ma_member_attribute_2.value IN ('urn:publicid:IDN+ch1.gpolab.bbn.com+user+ahelsing') AND pa_project_member_request.context_id = pa_project_member_1.project_id AND pa_project_member_1.role IN (1, 2) AND pa_project_member_request.status = 0
@ahelsing ahelsing added this to the unscheduled milestone Nov 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant