A
A
Artem [email protected]2018-07-03 09:53:56
Python
Artem [email protected], 2018-07-03 09:53:56

What is the best way to execute SQL?

There is a need to delete data from tables, create tables, the question is how best to implement this, what will be faster?
Call queries directly:

dbcur.execute = f"""DELETE FROM table_test WHERE mont = {mont}"""

or better via stored procedures:
dbcur.execute(f"EXECUTE DELETE_TABLE('{mont}')")

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ruslan., 2018-07-03
@LaRN

The stored procedure has an already compiled query plan (in MS SQL, Sybase this is exactly the case).
Theoretically, if the query is complex, the stored procedure will be faster by the time it takes the optimizer to build the plan.
But practically, on single queries, there will be no visible difference.

A
Andrey Burov, 2018-07-03
@BuriK666

Equally.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question