FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

use execute_many from backends directly by Mng-dev-ai · Pull Request #468 · encode/databases · GitHub

This repository was archived by the owner on Aug 19, 2025. It is now read-only.
/ databases Public archive

use execute_many from backends directly - #468

Open
Mng-dev-ai wants to merge 3 commits into
encode:masterfrom
Mng-dev-ai:use-execute_many-from-backends
Open

use execute_many from backends directly#468
Mng-dev-ai wants to merge 3 commits into
encode:masterfrom
Mng-dev-ai:use-execute_many-from-backends

Conversation

Mng-dev-ai commented Feb 22, 2022
edited
Loading

Copy link
Copy Markdown
Contributor

Fixes #284

Mng-dev-ai force-pushed the use-execute_many-from-backends branch from 8392da6 to 2107de3 Compare February 22, 2022 17:59

Copy link
Copy Markdown
Contributor Author

@aminalaee Any updates?

Comment thread databases/core.py
Comment on lines 279 to +281
queries = [self._build_query(query, values_set) for values_set in values]
async with self._query_lock:
await self._connection.execute_many(queries)
await self._connection.execute_many(queries, values)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Should we avoid building the queries here if you're going to compile them later?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hmm, it's been a long time since I wrote this PR, but I think we still need to convert the query to ClauseElement and bind params, but maybe we don't need list comprehension here, so maybe something like that is sufficient

async def execute_many(
        self, query: typing.Union[ClauseElement, str], values: list
    ) -> None:
        query = self._build_query(query,values[0])
        async with self._query_lock:
            await self._connection.execute_many(query, values)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hm interesting. I'm not sure myself, just wanted to check if you had considered it.

Thanks for chiming in on this after the delay. If you're interested in working on it again I can review and release it. Did you confirm this works and improves performance as expected?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I can work on it tmr for a few.
it should improve the performance but i didn't make any benchmarks tbh

Comment on lines +219 to +221
async def execute_many(
self, queries: typing.List[ClauseElement], values: typing.List[dict]
) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I presume this it not a breaking change for users because this is an internal method and values is always provided by us in the public method?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm not sure I understand what you mean here, but I think users are only supposed to use execute_many from the core file, not from any of the backends

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yep that's the question — I want to gauge if changing this function signature is a breaking change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

yea I don't think it should break anything

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Inserting to database using execute_many much slower than using fetch_all

3 participants


Back | FazBrowse Home | New Git URL