)]}'
{"blazar/db/sqlalchemy/utils.py":[{"author":{"_account_id":29270,"name":"Jacob Colleran","email":"jakecoll@uchicago.edu","username":"jakecoll2"},"change_message_id":"876f0ec74a1537c35f0a2b40af8f2d8ba6d85aaf","unresolved":false,"context_lines":[{"line_number":103,"context_line":"    query \u003d (session.query(models.Reservation.id,"},{"line_number":104,"context_line":"                           models.Reservation.lease_id,"},{"line_number":105,"context_line":"                           models.ComputeHostAllocation.compute_host_id)"},{"line_number":106,"context_line":"             .join(models.Lease).join(models.ComputeHostAllocation)"},{"line_number":107,"context_line":"             .filter(models.ComputeHostAllocation.compute_host_id"},{"line_number":108,"context_line":"                     .in_(host_ids))"},{"line_number":109,"context_line":"             .filter(sa.and_(border0, border1)))"}],"source_content_type":"text/x-python","patch_set":3,"id":"5faad753_f5d552b8","line":106,"updated":"2019-09-10 19:45:50.000000000","message":"I believe the fields need to be specified for the ORM to run this 3-table join efficiently. I posted a longer explanation of this in https://bugs.launchpad.net/blazar/+bug/1838025. Example below of fields to join:\n\n.join(models.Lease, \n      models.Lease.id \u003d\u003d models.Reservation.lease_id)\n.join(models.ComputeHostAllocation,\n      models.ComputeHostAllocation.reservation_id \u003d\u003d models.","commit_id":"0ba24e5a8b6746105492ab01af6d01e7880e42c9"},{"author":{"_account_id":15197,"name":"Pierre Riteau","email":"pierre@stackhpc.com","username":"priteau","status":"StackHPC"},"change_message_id":"9e0a0a894d71fe6817b396dab52142a6a52525cd","unresolved":false,"context_lines":[{"line_number":103,"context_line":"    query \u003d (session.query(models.Reservation.id,"},{"line_number":104,"context_line":"                           models.Reservation.lease_id,"},{"line_number":105,"context_line":"                           models.ComputeHostAllocation.compute_host_id)"},{"line_number":106,"context_line":"             .join(models.Lease).join(models.ComputeHostAllocation)"},{"line_number":107,"context_line":"             .filter(models.ComputeHostAllocation.compute_host_id"},{"line_number":108,"context_line":"                     .in_(host_ids))"},{"line_number":109,"context_line":"             .filter(sa.and_(border0, border1)))"}],"source_content_type":"text/x-python","patch_set":3,"id":"5faad753_ce466e22","line":106,"in_reply_to":"5faad753_7dc70414","updated":"2019-09-11 15:16:08.000000000","message":"SQLAlchemy should be using foreign keys to detect how best to join tables together: https://docs.sqlalchemy.org/en/13/orm/tutorial.html#querying-with-joins\n\nWe have those foreign keys defined. I suspect the problem is that the initial query already does a join+select on Reservation and ComputeHostAllocation and creates problems identifying keys for the next join.","commit_id":"0ba24e5a8b6746105492ab01af6d01e7880e42c9"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"683553501155191e3590b9364b23ca3ae83d791b","unresolved":false,"context_lines":[{"line_number":103,"context_line":"    query \u003d (session.query(models.Reservation.id,"},{"line_number":104,"context_line":"                           models.Reservation.lease_id,"},{"line_number":105,"context_line":"                           models.ComputeHostAllocation.compute_host_id)"},{"line_number":106,"context_line":"             .join(models.Lease).join(models.ComputeHostAllocation)"},{"line_number":107,"context_line":"             .filter(models.ComputeHostAllocation.compute_host_id"},{"line_number":108,"context_line":"                     .in_(host_ids))"},{"line_number":109,"context_line":"             .filter(sa.and_(border0, border1)))"}],"source_content_type":"text/x-python","patch_set":3,"id":"5faad753_7dc70414","line":106,"in_reply_to":"5faad753_f5d552b8","updated":"2019-09-11 01:47:51.000000000","message":"Reasonable enough. Done.","commit_id":"0ba24e5a8b6746105492ab01af6d01e7880e42c9"},{"author":{"_account_id":15197,"name":"Pierre Riteau","email":"pierre@stackhpc.com","username":"priteau","status":"StackHPC"},"change_message_id":"5b6ba6bdef6e65d5331be6834add72f23445a6a4","unresolved":false,"context_lines":[{"line_number":100,"context_line":"    session \u003d get_session()"},{"line_number":101,"context_line":"    border0 \u003d start_date \u003c\u003d models.Lease.end_date"},{"line_number":102,"context_line":"    border1 \u003d models.Lease.start_date \u003c\u003d end_date"},{"line_number":103,"context_line":"    query \u003d (session.query(models.Reservation.id,"},{"line_number":104,"context_line":"                           models.Reservation.lease_id,"},{"line_number":105,"context_line":"                           models.ComputeHostAllocation.compute_host_id)"},{"line_number":106,"context_line":"             .join(models.Lease,"},{"line_number":107,"context_line":"                   models.Lease.id \u003d\u003d models.Reservation.lease_id)"},{"line_number":108,"context_line":"             .join(models.ComputeHostAllocation,"}],"source_content_type":"text/x-python","patch_set":4,"id":"5faad753_4e64beb9","line":105,"range":{"start_line":103,"start_character":27,"end_line":105,"end_character":71},"updated":"2019-09-11 15:17:18.000000000","message":"Unless I am mistaken, I think this does an implicit join…","commit_id":"ddfa988e7b6df115606d68bbf65322cb050f9e4e"},{"author":{"_account_id":29270,"name":"Jacob Colleran","email":"jakecoll@uchicago.edu","username":"jakecoll2"},"change_message_id":"35698c57ee5bef605690c830f9bf0da19147c410","unresolved":false,"context_lines":[{"line_number":100,"context_line":"    session \u003d get_session()"},{"line_number":101,"context_line":"    border0 \u003d start_date \u003c\u003d models.Lease.end_date"},{"line_number":102,"context_line":"    border1 \u003d models.Lease.start_date \u003c\u003d end_date"},{"line_number":103,"context_line":"    query \u003d (session.query(models.Reservation.id,"},{"line_number":104,"context_line":"                           models.Reservation.lease_id,"},{"line_number":105,"context_line":"                           models.ComputeHostAllocation.compute_host_id)"},{"line_number":106,"context_line":"             .join(models.Lease,"},{"line_number":107,"context_line":"                   models.Lease.id \u003d\u003d models.Reservation.lease_id)"},{"line_number":108,"context_line":"             .join(models.ComputeHostAllocation,"}],"source_content_type":"text/x-python","patch_set":4,"id":"5faad753_ce098e31","line":105,"range":{"start_line":103,"start_character":27,"end_line":105,"end_character":71},"in_reply_to":"5faad753_4e64beb9","updated":"2019-09-11 15:40:53.000000000","message":"You may be right. My preference is to keep the explicit approach in your second comment.","commit_id":"ddfa988e7b6df115606d68bbf65322cb050f9e4e"},{"author":{"_account_id":15197,"name":"Pierre Riteau","email":"pierre@stackhpc.com","username":"priteau","status":"StackHPC"},"change_message_id":"5b6ba6bdef6e65d5331be6834add72f23445a6a4","unresolved":false,"context_lines":[{"line_number":105,"context_line":"                           models.ComputeHostAllocation.compute_host_id)"},{"line_number":106,"context_line":"             .join(models.Lease,"},{"line_number":107,"context_line":"                   models.Lease.id \u003d\u003d models.Reservation.lease_id)"},{"line_number":108,"context_line":"             .join(models.ComputeHostAllocation,"},{"line_number":109,"context_line":"                   models.ComputeHostAllocation.reservation_id \u003d\u003d"},{"line_number":110,"context_line":"                   models.Reservation.id)"},{"line_number":111,"context_line":"             .filter(models.ComputeHostAllocation.compute_host_id"},{"line_number":112,"context_line":"                     .in_(host_ids))"},{"line_number":113,"context_line":"             .filter(sa.and_(border0, border1)))"}],"source_content_type":"text/x-python","patch_set":4,"id":"5faad753_ee5a4af1","line":110,"range":{"start_line":108,"start_character":0,"end_line":110,"end_character":41},"updated":"2019-09-11 15:17:18.000000000","message":"So this can actually be removed?","commit_id":"ddfa988e7b6df115606d68bbf65322cb050f9e4e"},{"author":{"_account_id":15197,"name":"Pierre Riteau","email":"pierre@stackhpc.com","username":"priteau","status":"StackHPC"},"change_message_id":"45ff2edfa978e227a3678d43aa5954ac199a4b4f","unresolved":false,"context_lines":[{"line_number":105,"context_line":"                           models.ComputeHostAllocation.compute_host_id)"},{"line_number":106,"context_line":"             .join(models.Lease,"},{"line_number":107,"context_line":"                   models.Lease.id \u003d\u003d models.Reservation.lease_id)"},{"line_number":108,"context_line":"             .join(models.ComputeHostAllocation,"},{"line_number":109,"context_line":"                   models.ComputeHostAllocation.reservation_id \u003d\u003d"},{"line_number":110,"context_line":"                   models.Reservation.id)"},{"line_number":111,"context_line":"             .filter(models.ComputeHostAllocation.compute_host_id"},{"line_number":112,"context_line":"                     .in_(host_ids))"},{"line_number":113,"context_line":"             .filter(sa.and_(border0, border1)))"}],"source_content_type":"text/x-python","patch_set":4,"id":"5faad753_691df464","line":110,"range":{"start_line":108,"start_character":0,"end_line":110,"end_character":41},"in_reply_to":"5faad753_ee5a4af1","updated":"2019-09-11 15:42:24.000000000","message":"Functionally it works the same if removed, but the generated SQL is different: http://paste.openstack.org/show/775138/ (patch set 4) vs http://paste.openstack.org/show/775139/ (highlighted lines removed)","commit_id":"ddfa988e7b6df115606d68bbf65322cb050f9e4e"}]}
