SQL Server选择查询缓慢

时间:2019-05-25 16:48:42

标签: sql sql-server sql-tuning

我的SQL Server表中大约有820,000条记录,从表中选择数据需要5秒钟。该表在时间列上具有一个聚集索引,该索引可能为NULL(到目前为止,它不包含任何NULL值)。为什么只花这么多记录要花5到6秒钟?

2 个答案:

答案 0 :(得分:0)

“选择数据”是什么意思?如果要在Management Studio中获取这么多记录(显示所有记录),则通过显示所有行来消耗这6秒的大部分时间。如果是这种情况,只需将记录插入到临时表中即可。这样会更快。

答案 1 :(得分:0)

我向您推荐:

#include <Servo.h>// includes the servo moteur library
Servo myservo;
int y=0;

#include <Wire.h>
#include <LiquidCrystal_I2C.h> // includes the LiquidCrystal Library

LiquidCrystal_I2C lcd(0x27, 2, 1 , 0, 4, 5, 6, 7, 3, POSITIVE); // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)
const int place[]={13,12,11,10,9,8};
byte val[6];
const int in =7;
const int out =6;
int count=0;
int valin=0;
int valout=0;
int pos=51;
int cnt;

void setup() {

    Serial.begin(9600);
    for (int i=0;i<5;i++) {
        pinMode(place[i],INPUT);
    }

    pinMode(in,INPUT);
    pinMode(out,INPUT);

    myservo.attach(5);

    lcd.begin(16 , 2);

    lcd.setCursor(0, 0);
    lcd.print("systeme allumer");

    myservo.write(0);
    for (pos=51 ; pos>=0; pos--) {
        myservo.write(pos);
        delay(30);
    }
    delay(1000);
    for (pos=0; pos<=51; pos++) {
        myservo.write(pos);
        delay(30);
    }
    lcd.clear();
    lcd.setCursor(0, 0);
    count=0;
}


void loop() {

    lcd.setCursor(0, 0);
    lcd.print("P-L:");
    lcd.setCursor(0, 1);
    for(y=0;y<5;y++) {
        val[y]=digitalRead(place[y]);
        if(val[y]==1) {
            lcd.print(y+1);
        }
    }
    lcd.print("     ");
    valin=digitalRead(in);
    valout=digitalRead(out);

    if(count>=6) {
        count=6;
        myservo.write(0);
        delay(1000);
        myservo.detach();
        lcd.setCursor(5, 1);
        lcd.print("      FULL");
    }
    if(valout==LOW) {
        for(pos=51 ; pos>=0; pos--) {
            myservo.write(pos);
            delay(30);
        }

        while(valout==LOW) {
            valout=digitalRead(out);
        }
        count++;

        if(count<7){
        }
        delay(1000);
        for(pos =0; pos<=51; pos++) {
            myservo.write(pos);
            delay(30);
        }
    }

    if (valin==LOW) {
        myservo.attach(5);
        for(pos=51 ; pos>=0; pos--) {
            myservo.write(pos);
            delay(30);
        }
        while(valin==LOW) {
            valin=digitalRead(in);
        }
        count--;

        if(count<=0){
            count=0;
        }
        delay(1000);
        for(pos=0; pos<=51; pos++) {
            myservo.write(pos);
            delay(30);
        }
    }
    lcd.setCursor(10, 1);
    lcd.print(" cnt:");
    lcd.print(count);
    if(count>=6) {
        lcd.setCursor(5, 1);
        lcd.print("     FULL " );
    }
}
相关问题