Skip to content

Add consistent count of queries accross various batch orders #123

@jonenst

Description

@jonenst

Using ORMs (e.g. hibernate), often you don't really control the batch sizes (depends on how much the ORM can reorder statements). For example, when inserting 2x2 rows, you can have
insert into A
insert into B
insert into A
insert into B

or

insert into A
insert into A
insert into B
insert into B

In the second case, the ORM may batch with prepared statements, in which case the query count from DataSourceQueryCountListener becomes 2 instead of 4. (NOTE: if the batch is with statement instead of preparedstatement, the count would still show as 4; but for preparedstatement it is 2)

having a count that doesn't depend on batch order allows to write robust tests when batch orders is non deterministic.

Something like this ?
Change


to

            count.increment(type, queryInfo.getParametersList().size());

?

NOTE: Maybe both counts are important (single count for multiple data prepared statement and also multiple count for multiple data prepared statement) so maybe there needs to be 2 different APIs/names for these counts ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions