开发者

Is it faster to load XML all at once or bit by bit?

A quick question here: is it faster to load a large XML file (just one item per row), about 50,000 items, and parse it client side using JavaScript (I'm trying to find the rows that correspond to a certain date range), or is it faster to have PHP do the pre-parsing and send it to the client as it's needed? The thing is the PHP request开发者_开发知识库 would be about once every second, which seems a bit overboard - I'm trying to load points on a map, I expect each date range to have about 2000 points.

Thanks!


If you are bringing 1,000's of results back to the client every second you are going to have performance issues... That said if you are sending lots of data via AJAX I would recommend using JSON instead as there is much less overhead/content to send across the wire.

You also mentioned filtering on the server... Definitely filter out anything you don't need to send... Until you need to send it.


Both are dog slow. It seems like you shouldn't be using XML in the first place. Parsing and loading a huge XML takes time, searching the resulting tree too. Use a database, they're made for tasks like this, and they've been optimized for many many years. XML is not a database.

Anyway, caching will help vastly if you're expecting more than one user a day, and you should send the data to the client using a very lightweight format (JSON is propably the best bet) to minimize wasted bandwidth.


It depends. In this case, I'd suggest you measure.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜