codeant-ai-for-open-source[bot] commented on code in PR #46046: URL: https://github.com/apache/superset/pull/46046#discussion_r4485321960
########## superset/migrations/versions/2026-11-06_03-40_bccfd8e7dfa2_add_dttm_index_to_logs.py: ########## @@ -0,0 +1,47 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""Add dttm index to logs table + +Revision ID: bccfd8e7dfa2 +Revises: b8f3a2c91d64 +Create Date: 2026-11-06 03:40:00.000000 + +""" + +from superset.migrations.shared.utils import create_index, drop_index + +# revision identifiers, used by Alembic. +revision = "bccfd8e7dfa2" +down_revision = "b8f3a2c91d64" + +TABLE_NAME = "logs" +INDEX_NAME = "ix_logs_dttm" + + +def upgrade() -> None: + """Add an index on logs.dttm.""" + # logs' only index is (user_id, dttm) from cdcf3d64daf4, which leads with + # user_id -- most engines can't use a composite index to serve a lookup + # ordered on its trailing column alone. The Activity Log page lists logs + # ordered by dttm desc with no user filter (see LogMixin.base_order), so + # every visit is a full table scan without a dedicated index. + create_index(TABLE_NAME, INDEX_NAME, ["dttm"]) Review Comment: **Suggestion:** On PostgreSQL, this plain build blocks writes; building an index on a multi-million-row `logs` table can stall application log inserts for the migration's duration. **Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes` ยท ๐ท๏ธ `Performance` [](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=04a01ff5893641bdae1eb93c1c1e5a3a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=04a01ff5893641bdae1eb93c1c1e5a3a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) <details> <summary><b>Prompt for AI Agent ๐ค </b></summary> ```mdx This is a comment left during a code review. **Path:** superset/migrations/versions/2026-11-06_03-40_bccfd8e7dfa2_add_dttm_index_to_logs.py **Line:** 42:42 **Comment:** *Performance: On PostgreSQL, this plain build blocks writes; building an index on a multi-million-row `logs` table can stall application log inserts for the migration's duration. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F46046&comment_hash=2f7a23b8c75da74a1f6dbcb77f922a494c57d997bf3ba5b08244d0dd6035c075&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F46046&comment_hash=2f7a23b8c75da74a1f6dbcb77f922a494c57d997bf3ba5b08244d0dd6035c075&reaction=dislike'>๐</a> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
