Uploading text data to server from SQLite is faster or text files?

My application receives a lot of data every milliseconds(name,id,value,.. of a signal from a simulator device). and I should upload this data to MySQL server. First I need to save them in a database and upload them to the server via GSM network. The reason that I save data into the mobile device is that the connection is so slow and the app receives a quite large number of data at a time and cannot upload them at once, also it may encounter disconnection problem. In fact, I just need a temporary storage and I don’t want to do any data manipulation in the SQLite. Currently I am writing the data to the simple text file(CSV) and then upload every 20 lines to the server using name/value pairs in Android HttpPost, but what about SQLite? Is it faster to insert data to SQLite and then upload it? Which approach is preferable?

Here is the sample data that I receive from the simulator device:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
time,id,name,value
143125738713,id1,name1,8.000077
143125738714,id1,name1,8.000004
143125738714,id1,name1,8.000008
143125738715,id2,name2,0.0
143125738716,id2,name2,0.0
time,id,name,value 143125738713,id1,name1,8.000077 143125738714,id1,name1,8.000004 143125738714,id1,name1,8.000008 143125738715,id2,name2,0.0 143125738716,id2,name2,0.0
time,id,name,value
143125738713,id1,name1,8.000077
143125738714,id1,name1,8.000004
143125738714,id1,name1,8.000008
143125738715,id2,name2,0.0
143125738716,id2,name2,0.0

For a definitive answer, one would have to measure, and I am sure it will be possible to create a badly implemented CSV writer which is slower than a well written SQLite writer.

However, when it comes to writing sequential data records to a file, there is not much out there which can beat using to a simple file stream in speed. Each additional layer of abstraction upon that will probably slow your program down. Thus I would not expect writing to a text file to be slower than writing to any kind of database, even it is as lightweight as SQLlite, as long as there is not any “performance bug” in the program.

If speed is your main concern, and the network connection is your bottleneck, you may consider to apply some kind of data compression before sending the files over the line, and decompress it on the server before inserting it.

SQLite is awesome but it is “not optimised” for insert speed (but note that you can run it in significantly faster ‘async’ mode which will not protect your data if something crashes – this may be acceptable for your use-case if you don’t mind losing some of those data points)

You’ll be better off appending to a filestream.

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