当表有数千条记录时,Sql TOP 1查询执行速度很慢?

时间:2016-01-15 06:48:19

标签: sql sql-server-2008

当表有数千条记录时,Sql TOP 1查询执行速度很慢?

select Top 1 * from AA011 WHERE order By datadate DESC

2 个答案:

答案 0 :(得分:2)

查看查询的执行计划。

您很可能会看到类似表/聚簇索引扫描然后排序的内容。这意味着您没有在表的datadate字段上构建索引 - 因此SQL服务器必须从表中检索所有数据并对其进行排序以获得前1个值。

如果要在此列上构建索引,SQL Server将使用此索引而不是检索所有数据并对其进行排序 - 因此它将大大提高性能。

答案 1 :(得分:1)

"use strict"; var path = require('path'); var webpack = require('webpack'); var bower_dir = path.join(__dirname, '/bower_components'); var HtmlWebpackPlugin = require('html-webpack-plugin'); var config = { addVendor: function(name, path){ this.resolve.alias[name] = path; this.module.noParse.push(path); }, entry: { app: ["./app/js/index.js"], vendors: ["d3", "_"] }, output: { "path": process.env.NODE_ENV === 'production' ? './dist' : './build', "filename": "bundle.js" }, module: { noParse: [], loaders: [ { test: /\.css$/, loader: "style-loader!css-loader?root=." }, { test: /\.js?$/, exclude: /(node_modules|bower_components)/, loader: 'babel' }, { test: /\.gif$/, loader: "url-loader?mimetype=image/png" }, // { test: /bootstrap\/js\//, loader: 'imports?jQuery=jquery' }, { test: /.(png|woff(2)?|eot|ttf|svg)(\?[a-z0-9=\.]+)?$/, loader: 'url-loader?limit=100000' } ] }, resolve: { alias: {}, root: [path.join(__dirname, "app/css"), path.join(__dirname, "app/js")] }, plugins: [ // This plugin makes a module available as variable in every module new webpack.ProvidePlugin({ d3: "d3", "_": "_" }), // CommonsChunkPlugin will take the vendors chunk and create a commonly used js file new webpack.optimize.CommonsChunkPlugin('vendors','vendors.js', Infinity), // https://www.npmjs.com/package/html-webpack-plugin new HtmlWebpackPlugin({ title: 'D3 and react', template: 'build/index.html' }) ] }; config.addVendor('d3', bower_dir + '/d3/d3.min.js'); config.addVendor('_', bower_dir + '/lodash/lodash.min.js'); module.exports = config; 列上创建clustered index,以加快流程

datadate