Comments (7)
How many messages are there? Is there an index on the room or on messages.originalId
(there should be one if you're using foreign key constraints and have the foreign key pragma enabled)?
How are you opening the database, are you using NativeDatabase.createInBackground
?
from drift.
@simolus3 The laggy I didn't occured previous or not very severe, but recently, when I did something :
I using RxList to contains mssages (with GetX), then for every get have messages.bindStream() operation
Is that possible the issue to cause laggy? It looks like will subscribe streams again and again.
Also, the messages here are 32 max for one batch, and maybe 64 for 2 batch, not too much.
from drift.
then for every get have messages.bindStream() operation
I wasn't aware of RxList
before, which package is providing messages.bindStream()
or what is that doing?
It looks like will subscribe streams again and again.
Drift is kind of optimized for this since the StreamBuilder
widget can cause similar things. If you cancel a subscription and then re-subscribe to it reasonably quickly (one event loop iteration between those, we cancel streams after one Timer.run
iteration), the query should not be run again.
from drift.
It's GetX, widely used, it provides a way to do stream like behavior but simpler, RxList a can a.bindSream to make it use streams return by drift.
Since GetX so widely used, am just wonder the reason, why I using a.bindStream in every time get data from sql and stream to UI got laggy.
One possible reasons is that, when I get data from sql and bindStream, if there is a sql update, and then same time updating UI (since it's stream), it might got some kind of race trace problem
from drift.
Are you calling close()
on the rx objects after you don't need them anymore? If you have thousands of "different" streams in drift (different SQL or different parameters), the lag would be unavoidable. It looks like there is no way to unsubscribe from a stream after passing it to bindStream
without closing the rx object.
One possible reasons is that, when I get data from sql and bindStream
Why do you call bindStream
every time? Do you have a way to use switchMap
to combine multiple streams into one if you don't need all of them at once?
from drift.
@simolus3 I didn't called close() anywhere, since this is a APP lifecycle object to be called.
but the bindStream might called many times eveytime I enter the page, it will be called in initState
func.
Where could I close the stream on UI? dispose or somwhere? Does bindStream many times will casued UI laggy?
from drift.
dispose or somwhere? Does bindStream many times will casued UI laggy?
It looks like there is no way to cancel a stream passed to bindStream
, so yeah - from a quick look it appears as that method inherently leaks resources.
But let's merge this discussion into #2838, which appears to be about the same problem.
from drift.
Related Issues (20)
- Views code generation HOT 9
- Cannot test migrations using modular approach with store_date_time_values_as_text: true HOT 4
- Unable to override `runs_before` in `build.yaml` due to `Unrecognized keys` exception HOT 2
- Support remote SQLite databases HOT 8
- drift_flutter package doesn't exist HOT 3
- WEB build db queries returns nothing from a prefilled db HOT 5
- Migration Error when altered same table twice. HOT 1
- Missing `extensions` Import in Generated Code HOT 1
- Add Code Generation for json_serializable HOT 2
- android::register_android_database_SQLiteConnection Android Crash HOT 2
- insertOnConflictUpdate behaves as an insert HOT 8
- Adding unique key that is case-insensitive HOT 1
- `pragma legacy_alter_table = 1` not supported in Turso HOT 4
- [WEB] Can't run a transaction inside `exclusively` HOT 1
- v2.19.0 introduced a breaking change HOT 3
- 404 link in QueryExecutor class documentation HOT 1
- Renew DriftDatabase usage example HOT 1
- feat: Declare column on table with `late final`
- Unhandled Exception: Bad state: Tried to send Request ... over isolate channel, but the connection was closed! HOT 3
- DevTools extension not working in 2.19.1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drift.