dongqijuan3786 2015-07-24 07:50
浏览 84

性能问题 - 从Navision获取数据到PHP API

I'm currently creating an API that has access to our Navision system. I'm pretty new to this, but I only added some functionality to an already existing system. The thing is:

UPDATE 2:

I think the version of Navision is irrelevant, since I'm querying the MSSQL database attached directly. Maybe the version of the MSSQL DB could be relevant:

Microsoft SQL Server 2012 - 11.0.2218.0 (X64) Jun 12 2012 13:05:25 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1) (Hypervisor)

UPDATE:

I have already iterated over the CSV file and also the the search query is done every time a get a new email, since it cannot call the MSSQL server with an IN() statement with 70.000 emails in it.

I have also only opened the csv file for writing once instead of on every request.

Completed:

  • I have a csv file with a lot of emails (done)
  • This should be uploaded (done)
  • The uploaded file should then be parsed for emails (done)
  • The emails should then be matched up with the ones in Navision (done)

Problem:

  • It takes a lot of time doing this
  • Navision turns slow and there is a lot of people depending on that system on a daily basis.

Info:

  • There are approx. 70.000 emails in the CSV file (and counting)
  • We have approx. 1 million customers in Navision
  • This script is supposed to run daily.
  • Currently there is no joins in the SQL statement (this will come)

Do any of you have any suggestions on how to optimize the process?

Any help will be appreciated.

// Ulrik McArdle

  • 写回答

1条回答 默认 最新

  • douhan6738 2015-07-24 08:09
    关注

    Without knowing the details of how you've implemented the process it is impossible to talk specifics. But, here are a couple of common pitfalls to avoid:

    1) When writing a script to parse a large text CSV text file, do so line by line. Do not try to load the file into memory - into a gargantuan array or some such. This is hugely inefficient. Rather, open the file and iterate over it line by line using something like a while loop and fgetcsv(), process that line, throw it away and load another.

    2) Make the RDBMS - MySQL, Oracle, Postgres, whatever - handle the heavy work. PHP is not the place to process the data. Optimise the SQL statements, in other words. I would assume that the "Navision turns slow" bit would best attended by attention to the SQL.

    评论

报告相同问题?

悬赏问题

  • ¥15 求指导ADS低噪放设计
  • ¥15 CARSIM前车变道设置
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存