<div dir="ltr"><div>Hello,</div><div><br></div><div>A few weeks ago, I took a look at the TSQLScript (that IMHO is a very nice class!) source, and I noticed that it seems slow for processing big files.</div><div><br></div><div>I did some tests with this class. My SQL file: 90 MB, with CREATE TABLE, CREATE PROCEDURE, CREATE TRIGGER, ALTER TABLE, several INSERT INTO and more. Using the current TSQLScript implementation, the execution of this file is very slow, and the CPU/memory usage is extremely large(*), but after make some changes in the original TSQLScript source code, adapting it to use this[1] new class (recently applied in FCL), I got a significant difference, ie, the CPU/memory usage now is amazing less, increasing the performance +-80%. =) The answer to the significant gain is simple: using a textreader, the TSQLScript class read the SQL (from string, stream or file) by demanding (line by line, and using a low level byte reading too), instead of loading an entire file to a buffer in a stringlist.</div><div><br></div><div>So, after this explanation, what do you think about TSQLScript using textreader? I can send a patch showing this idea as a real implementation, of course, keeping the 'Script' as a stringlist, just adding a new property, called 'Source' and declared as 'TTextReader'.</div><div><br></div><div>An observation: I suspect it has a small bug at this line[2]: the 'Directive' variable could break the loop skipping for the next line after its assignment. OK, if it is a bug, it is very easy to fix.</div><div><br></div><div>(*) In a specific case on a Linux server, the kernel killed my executable while importing my SQL file, see more details here[3].</div><div>[1] <a href="http://bugs.freepascal.org/view.php?id=28075" target="_blank">http://bugs.freepascal.org/view.php?id=28075</a></div><div>[2] <a href="https://github.com/graemeg/freepascal/blob/master/packages/fcl-db/src/base/sqlscript.pp#L387" target="_blank">https://github.com/graemeg/freepascal/blob/master/packages/fcl-db/src/base/sqlscript.pp#L387</a></div><div>[3] <a href="http://unix.stackexchange.com/questions/136291/will-linux-start-killing-my-processes-without-asking-me-if-memory-gets-short" target="_blank">http://unix.stackexchange.com/questions/136291/will-linux-start-killing-my-processes-without-asking-me-if-memory-gets-short</a></div><div><br></div><div>-- </div><div>Silvio Clécio</div><div>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a></div><div>
</div></div>