SQLite查询使用TEMP B-TREE FOR ORDER BY而不是索引

时间:2016-07-11 23:45:59

标签: sqlite sorting indexing query-planner

我有一个非常简单的表,其中包含2列,message_id和server_timestamp,但是当我查看此查询的计划时:

i+1

其中index_messages_id_server_timestamp是(message_id,server_timestamp)上的索引。

为什么此查询需要使用临时b树进行排序?

1 个答案:

答案 0 :(得分:1)

由于GROUP BY,表的多行可能会在输出中产生一行。这打破了import UIKit import AVFoundation class ViewController: UIViewController { let captureSession = AVCaptureSession() let stillImageOutput = AVCaptureStillImageOutput() var error: NSError? override func viewDidLoad() { super.viewDidLoad() let devices = AVCaptureDevice.devices().filter{ $0.hasMediaType(AVMediaTypeVideo) && $0.position == AVCaptureDevicePosition.Back } if let captureDevice = devices.first as? AVCaptureDevice { captureSession.addInput(AVCaptureDeviceInput(device: captureDevice, error: &error)) captureSession.sessionPreset = AVCaptureSessionPresetPhoto captureSession.startRunning() stillImageOutput.outputSettings = [AVVideoCodecKey:AVVideoCodecJPEG] if captureSession.canAddOutput(stillImageOutput) { captureSession.addOutput(stillImageOutput) } if let previewLayer = AVCaptureVideoPreviewLayer(session: captureSession) { previewLayer.bounds = view.bounds previewLayer.position = CGPointMake(view.bounds.midX, view.bounds.midY) previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill let cameraPreview = UIView(frame: CGRectMake(0.0, 0.0, view.bounds.size.width, view.bounds.size.height)) cameraPreview.layer.addSublayer(previewLayer) cameraPreview.addGestureRecognizer(UITapGestureRecognizer(target: self, action:"saveToCamera:")) view.addSubview(cameraPreview) } } } func saveToCamera(sender: UITapGestureRecognizer) { if let videoConnection = stillImageOutput.connectionWithMediaType(AVMediaTypeVideo) { stillImageOutput.captureStillImageAsynchronouslyFromConnection(videoConnection) { (imageDataSampleBuffer, error) -> Void in let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(imageDataSampleBuffer) UIImageWriteToSavedPhotosAlbum(UIImage(data: imageData), nil, nil, nil) } } } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } } message_id值之间的关系,因此不再可能证明使用索引对它们进行排序是有效的。