mistercrunch commented on issue #30064:
URL: https://github.com/apache/superset/issues/30064#issuecomment-2330331216

   One idea that may help if you want to try it @mapledan 
   
   ```python
   from sqlalchemy import text
   from sqlalchemy.engine import Connection
   
   @staticmethod
   def get_queries_changed_after(last_updated_ms: Union[float, int]) -> 
list[Query]:
       # UTC date time, same that is stored in the DB.
       last_updated_dt = datetime.utcfromtimestamp(last_updated_ms / 1000)
   
       # Check the database dialect and apply AUTOCOMMIT only for supported 
databases
       if db.session.bind.dialect.name in ["postgresql", "mysql"]:
           return (
               db.session.query(Query)
               .filter(Query.user_id == get_user_id(), Query.changed_on >= 
last_updated_dt)
               .execution_options(isolation_level="AUTOCOMMIT")  # Use 
AUTOCOMMIT for compatible databases
               .all()
           )
       else:
           return (
               db.session.query(Query)
               .filter(Query.user_id == get_user_id(), Query.changed_on >= 
last_updated_dt)
               .all()
           )
   ```
   in this module -> superset/models/sql_lab.py
   
   Wanna try it and report-back?
   
   BTW I double checked that we have a proper index on `user_id, changed_on` to 
make sure that polling query is as fast as can be. 


-- 
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]

Reply via email to