Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@AlexRiedler
Copy link
Contributor

Given the simple example as provided in the documentation provided (see https://www.ktorm.org/en/query.html)

val query = database.from(Employees).select()

query
    .map { row -> Emp(row[Employees.id], row[Employees.name], row[Employees.salary]) }

this will actually generate a label per row per column in order to access the element in the table via call stack of:

QueryRowSet.get(Column)
Column.getLabel()
Column.toString("_")

however, this getter initializes a string on every instance, so if you have 1000 rows, this will generate 1000 strings x the number of columns that are all the same for every call.

Alternative approaches

  • Initialize the string when initializing the Column itself (not using lazy)
  • Use lazy with a different synchronization mode

As always, thanks for reading and maintaining the library!

@vincentlauvlwj vincentlauvlwj changed the base branch from master to dev July 12, 2024 09:33
@vincentlauvlwj vincentlauvlwj merged commit 2e2ab58 into kotlin-orm:dev Jul 12, 2024
@vincentlauvlwj
Copy link
Member

Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants