English 中文(简体)
5. 优化咨询
原标题:SQLite query optimization

I m利用这个电线在用户附近的地点。

query = [NSString stringWithFormat:@"SELECT place_index, place_name,  place_category, place_address, place_phone, place_mobile, place_description, place_email, place_website, place_facebookId, place_neighborhood, place_rating, place_lat, place_long, place_is_closed, product_name, distance(place_lat, place_long,  %f ,  %f ) AS dist FROM (SELECT places.id as place_index, places.name as place_name, places.category as place_category, places.address as place_address, places.phone as place_phone, places.mobile as place_mobile, places.description as place_description, places.email as place_email, places.website as place_website, places.facebookId as place_facebookId, places.neighborhood as place_neighborhood, places.rating as place_rating, places.lat as place_lat, places.long as place_long, places.is_closed as place_is_closed, products.name as product_name FROM places LEFT JOIN products ON products.place_id = places.id UNION SELECT places.id as place_index, places.name as place_name,  places.category as place_category, places.address as place_address, places.phone as place_phone, places.mobile as place_mobile, places.description as place_description, places.email as place_email, places.website as place_website, places.facebookId as place_facebookId, places.neighborhood as place_neighborhood, places.rating as place_rating, places.lat as place_lat, places.long as place_long, places.is_closed as place_is_closed, added_products.name as added_product_name FROM places LEFT JOIN added_products ON added_products.place_id = places.id) WHERE place_is_closed = 0 ", userLocation.coordinate.latitude, userLocation.coordinate.longitude];

基本上,我从自由党加入的遴选联盟中挑选出来。 这一查询在搜索机制中使用,因此每当用户输入一个<编码>UIText Field。 采用第1号 impos令来实施和取用物体,是否有办法优化这种物体?

页: 1

这是问答案文,上文列出格式参数,但我不认为它们是一个问题:

SELECT place_index, 
       place_name, 
       place_category, 
       place_address, 
       place_phone, 
       place_mobile, 
       place_description, 
       place_email, 
       place_website, 
       place_facebookid, 
       place_neighborhood, 
       place_rating, 
       place_lat, 
       place_long, 
       place_is_closed, 
       product_name, 
       Distance(place_lat, place_long,  %f ,  %f ) AS dist 
FROM   (SELECT places.id           AS place_index, 
               places.name         AS place_name, 
               places.category     AS place_category, 
               places.address      AS place_address, 
               places.phone        AS place_phone, 
               places.mobile       AS place_mobile, 
               places.DESCRIPTION  AS place_description, 
               places.email        AS place_email, 
               places.website      AS place_website, 
               places.facebookid   AS place_facebookid, 
               places.neighborhood AS place_neighborhood, 
               places.rating       AS place_rating, 
               places.lat          AS place_lat, 
               places.long         AS place_long, 
               places.is_closed    AS place_is_closed, 
               products.name       AS product_name 
        FROM   places 
               LEFT JOIN products 
                 ON products.place_id = places.id 
        UNION 
        SELECT places.id           AS place_index, 
               places.name         AS place_name, 
               places.category     AS place_category, 
               places.address      AS place_address, 
               places.phone        AS place_phone, 
               places.mobile       AS place_mobile, 
               places.DESCRIPTION  AS place_description, 
               places.email        AS place_email, 
               places.website      AS place_website, 
               places.facebookid   AS place_facebookid, 
               places.neighborhood AS place_neighborhood, 
               places.rating       AS place_rating, 
               places.lat          AS place_lat, 
               places.long         AS place_long, 
               places.is_closed    AS place_is_closed, 
               added_products.name AS added_product_name 
        FROM   places 
               LEFT JOIN added_products 
                 ON added_products.place_id = places.id) 
WHERE  place_is_closed = 0 
最佳回答

将该次顺序作为<代码><> > >表中唯一一个识别栏,并在身份栏顶上增加一个新的JOIN。 这应当使子类计算更轻。

问题回答

暂无回答




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签