-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
QST: to_sql is unnecessarily blocked because of dependency on information_schema tables #52601
Comments
Thanks for your report. Investigations welcome. |
Interesting, this solved my problem - getting |
Not sure if anyone else has tracked down the issue. This is caused by check_case_sensitive in pandas.io.sql.py This is because of the get_table_names method in sqlalchemy.dialects.mssql.base.py not using a nolock hint |
Thanks @jacobshaw42 for tracking it down! highlighting both lines below.
Do you want to create an issue on SqlAlchemy repo? Otherwise, I can. edit: i think it is something Pandas should solve, actually. it should only do the case sensitivity check for database with case sensitivity. i'm also unsure if it should be doing it at all. |
I tested changing the isolation level to It still would be good to have a better solution - still unclear if SQLAlchemy needs to fix or Pandas?
|
Thanks for the confirmation. I am actually use dask, which takes the uri instead of the full engine. Attempted to pass
to the dask to sql method, but it still got blocked. I will create and issue under sqlalchemy |
Research
I have searched the [pandas] tag on StackOverflow for similar questions.
I have asked my usage related question on StackOverflow.
Link to question on StackOverflow
https://stackoverflow.com/questions/64610269/sqlalchemy-hangs-during-insert-while-querying-information-schema-tables
Question about pandas
I'd like to bring attention to this issue where
to_sql
is being blocked by an unrelated process because pandas requires checkinginformation_schema
metadata tables.My example is
MSSQL
(SQL Server) specific but I think it could apply to other DB systems.steps to reproduce:
information_schema
Other scenarios that lock
information_schema
cause this blocking in pandas (rebuilding clustered columnstore index on large table)Notes
In my opinion, we should be able to insert into an existing table no matter if there are other processes going on.
for someone who knows the pandas internals, maybe they can chime in?
see relevant Stack Overflow question
Sqlalchemy GH issue - SQLAlchemy hangs during insert while querying [INFORMATION_SCHEMA].[TABLES] when an open transaction exists that has created a new table sqlalchemy/sqlalchemy#5679
Root cause
**SQL code to create unrelated table **
code i used for testing the python piece
checking the server, this is the hung query called by pandas/sqlalchemy
Pandas is blocked in loading into the table
The text was updated successfully, but these errors were encountered: