优化查询,花费太长时间

时间:2020-10-14 18:13:50

标签: sql reactjs material-table

我有以下查询返回2100条记录,但是显示结果花费的时间太长了

有什么方法可以减少咨询时间?

select 
    ClaCte, 
    lTRIM(RTRIM(NomCte)) NomCte, 
    ClaEmp, 
    ClaZona, 
    ClaGiroCom  
from Cliente WITH(NOLOCK) 
where ClaEmp in (3,4) 
and ClaZona not in (97,98)

我正在使用React和Material-Table,所以我在React方法中有这个查询

我的代码React

const loadCustumers = async () => {
let i = 0;
var params = {
  input: {
    request: "{ \"query\": \"select top 2000 ClaCte, lTRIM(RTRIM(NomCte)) NomCte, ClaEmp, ClaZona, ClaGiroCom  from Cliente WITH(NOLOCK) where ClaEmp in (3,4) and ClaZona not in (97,98) \", \"server\": \"SFORTIA\", \"database\": \"NICANOR_ERP\" }",
    startDate: parseInt(new Date().getTime() / 1000),
    sync: false,
    source: "fortia_erp"

  }
}
api(createRemoteRequest, params)
  .then((res) => {

    subscribeRemoteRequests(res.id)

  })
  .catch((err) => {
    console.log(err);
  });
};



const subscribeRemoteRequests = (id) => {
// Subscribe to creation of Todo
subscriptionRemoteRequests = API.graphql(
  graphqlOperation(onUpdateRemoteRequest, { id: id })
).subscribe({
  next: (todoData) => {
    // Do something with the data
    if (todoData && todoData.value && todoData.value.data && todoData.value.data.onUpdateRemoteRequest && todoData.value.data.onUpdateRemoteRequest.response && todoData.value.data.onUpdateRemoteRequest.id === id) {
      let response = JSON.parse(todoData.value.data.onUpdateRemoteRequest.response);
      console.log(response)
      setCustomerList(response);
    }
  }
});
 }

 const SelectRows = (rows) => {
 console.log(rows)

 setListSelectCustumer(rows)
 }

0 个答案:

没有答案