question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Super slow speed on large data set of floating numbers for SELECT operation

See original GitHub issue

SQLDelight Version

1.5.3

Application Operating System

Android

Describe the Bug

Problem

Perfoming the following operation: Given a dataset of 1000 elements that contain floating numbers, perform SELECT * operation Takes a huge amount time (>1500 milliseconds), but it shouldn’t

Code snippet

WeatherLog.sq

CREATE TABLE weatherLog(
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    temperature REAL,
    humidity REAL,
    pressure REAL
);

selectAll:
SELECT *
FROM weatherLog;

WeatherDbDataSource

    override suspend fun loadAll() {
        weatherLogQueries.selectAll()
    }

Performance result

SQLDelight performance screenshotperformance screenshot

Why is this a bug

The same operation takes no time on Room. Since both are wrappers over SQLite I expect the results of SQLDelight to be similar to Room. They are similar for strings. But not for real numbers, hence I assume there is a bug

Room performance screenshotperformance screenshot

Stacktrace

There are no errors in stacktrace

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
AlecStrongcommented, Jun 17, 2022

👍 indeed very weird. I can take a look

1reaction
AlecStrongcommented, Jun 17, 2022
    override suspend fun loadAll() {
        weatherLogQueries.selectAll()
    }

this isn’t running any SQL, it’s just creating the query type

Read more comments on GitHub >

github_iconTop Results From Across the Web

Speed in Python - Practical Data Science
But understanding why programs like Python can sometimes be slow is still ... And because integers and floating point numbers are different things...
Read more >
Chapter 4. Query Performance Optimization - O'Reilly
Slow Query Basics: Optimize Data Access. The most basic reason a query doesn't perform well is because it's working with too much data....
Read more >
Why does changing 0.1f to 0 slow down performance by 10x?
Denormal (or subnormal) numbers are kind of a hack to get some extra values very close to zero out of the floating point...
Read more >
What Every Computer Scientist Should Know About Floating ...
One approach represents floating-point numbers using a very large significand, ... But accurate operations are useful even in the face of inexact data, ......
Read more >
Floating-point arithmetic - Wikipedia
For this reason, floating-point arithmetic is often used to allow very small and very large real numbers that require fast processing times.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found