Design Question: Keep 1000 newest items; DB vs. application

I have a Qt application, which sends and receives messages. Messages are stored in a local MongoDB.

The application has a message list window, which shows sent, received and all messages (depending on the view). For performance reasons the application has a QList, which holds QPairs of Mongo ID and the message itself, so more or less all messages are available in the application.

We want to limit the no. of shown messages, because the view gets slower for 1000 and more messages.

The simple approach was just to limit the no. of pairs stored in the QList.

However, I’m not quite sure, if this is true. Recently I’ve read here (EDIT: found it) a question which basically said “Your application code won’t be smarter/faster/better for stuff a DB is designed for (e.g. sorting, getting a subset, etc.)”.
In addition keeping the QList in sync with the DB is causing us headaches and we have some corner cases like an very old message can be updated and then has to be displayed again.

So the question is, would a DB-only approach (e.g. querying the DB for 1000 messages whenever the view has to be updated) be faster then storing the acutally shown messages in the QList and trying to keep them in sync.

4

This seems more like a separation of concerns between the: QList, view and MongoDB.

Focus on the purpose of the QList and then make sure the synch capabilities get the job done. Do you need all the records for some purpose outside of the view?

We want to limit the no. of shown messages, because the view gets
slower for 1000 and more messages.

If the QList for whatever purpose outside of displaying a view, needs to hold more than the 1000 view limit, you need something else to limit the records coming from the QList to the view (if that’s how you need it to work.). Otherwise, you may need some other logic pulling the MongoDB data with a 1000 record limit with the sole purpose of feeding the view.

Is the limitation of the view (not sure exactly what that is) holding enough records in memory or the control you’re using as the display for the user (Data Grid, Combo Box, repeater, etc.)?

1

It’s impossible to say whether loading from the database will be faster without running some tests or knowing how often the window gets refreshed. My guess is that the perceived performance loading or working in the messages window will become constant rather than getting worse as the number of messages increases.

A not-insignificant upside to it would be simplifying your code a bit – you’ll no longer need any code to keep the list in sync with the database. You’ll just grab the latest (perhaps configurable number of) messages when loading or refreshing the messages window, so you won’t have to worry about stale data.

As you said in a comment:

Let’s say 300 would probably be also sufficient.

Retrieving a very small amount of data from the database will very likely not be noticeably slower, and if 300 messages can cover 90% of use cases and you can provide a way for users to retrieve older messages when needed, I bet you’ll come out ahead performance-wise.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Design Question: Keep 1000 newest items; DB vs. application

I have a Qt application, which sends and receives messages. Messages are stored in a local MongoDB.

The application has a message list window, which shows sent, received and all messages (depending on the view). For performance reasons the application has a QList, which holds QPairs of Mongo ID and the message itself, so more or less all messages are available in the application.

We want to limit the no. of shown messages, because the view gets slower for 1000 and more messages.

The simple approach was just to limit the no. of pairs stored in the QList.

However, I’m not quite sure, if this is true. Recently I’ve read here (EDIT: found it) a question which basically said “Your application code won’t be smarter/faster/better for stuff a DB is designed for (e.g. sorting, getting a subset, etc.)”.
In addition keeping the QList in sync with the DB is causing us headaches and we have some corner cases like an very old message can be updated and then has to be displayed again.

So the question is, would a DB-only approach (e.g. querying the DB for 1000 messages whenever the view has to be updated) be faster then storing the acutally shown messages in the QList and trying to keep them in sync.

4

This seems more like a separation of concerns between the: QList, view and MongoDB.

Focus on the purpose of the QList and then make sure the synch capabilities get the job done. Do you need all the records for some purpose outside of the view?

We want to limit the no. of shown messages, because the view gets
slower for 1000 and more messages.

If the QList for whatever purpose outside of displaying a view, needs to hold more than the 1000 view limit, you need something else to limit the records coming from the QList to the view (if that’s how you need it to work.). Otherwise, you may need some other logic pulling the MongoDB data with a 1000 record limit with the sole purpose of feeding the view.

Is the limitation of the view (not sure exactly what that is) holding enough records in memory or the control you’re using as the display for the user (Data Grid, Combo Box, repeater, etc.)?

1

It’s impossible to say whether loading from the database will be faster without running some tests or knowing how often the window gets refreshed. My guess is that the perceived performance loading or working in the messages window will become constant rather than getting worse as the number of messages increases.

A not-insignificant upside to it would be simplifying your code a bit – you’ll no longer need any code to keep the list in sync with the database. You’ll just grab the latest (perhaps configurable number of) messages when loading or refreshing the messages window, so you won’t have to worry about stale data.

As you said in a comment:

Let’s say 300 would probably be also sufficient.

Retrieving a very small amount of data from the database will very likely not be noticeably slower, and if 300 messages can cover 90% of use cases and you can provide a way for users to retrieve older messages when needed, I bet you’ll come out ahead performance-wise.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật