
Bill Wonders (Partner) asked a question.
We have an SQL query that took 30 minutes previously, after changing the DB to utf-8 with ICU-UCA conv, the same query now takes 3+ hours.
Same database, same data, same scan
Full record read of 46 columns: 4 seconds
Same read with 40 PRO_ELEMENT calls: 40 seconds
Was 30–40 minutes for the full extract before Basic → UTF-8/ICU-UCA, now 3+ hours
NULLIF removal gained 27%,
CONVERT removal gained nothing
Indexes rebuilt, statistics current, SQL widths fixed, fragmentation ruled out.
Anyone got any suggestions as to how I get it back to 30 minutes without converting the DB back to utf-8/basic?
That is a big performance difference. Can you share the quantity of data in some way? 5 million rows? 50 million rows? 500 million rows?
If you repeatedly run the query is the behavior always the same?
Can you tell us what resource is limiting the query? Opening up task manager should quickly tell you if it is throttled on CPU or not (I assume so). Another possibility is network, in which case the following paragragh becomes super important.
Unfortunately this OE SQL engine always runs single-threaded plans. If you have lots of cores, you could split the work into lots of independent queries and run then in parallel (eg. with C# parallel foreach or something of that nature).
The right place to start with this question is to find out what query plan the SQL engine is using. Maybe your plan is the same before/after? Here is the way to get the plan:
https://www.google.com/search?q=how+to+get+a+query+plan+from+progress+OE+sql
If I were you I would strip out that 40 pro_element array, and move it to a different table after pivoting it. Those extent fields in OE are not a good idea, even back in the day. If they were a good idea, you would see all the other OLTP databases doing a similar thing. The nearest thing you find in other databases is the ability to offer full support for json or xml (which is far more useful and flexible, IMO).
Also please note that you should be able to get all 40 of the PRO_ELEMENT in one single use of that function. You just need a capable client on the receiving end to parse and distinguish the results. The SQL engine runs native instructions, but even so you don't want it burdened with work that could just as easily be done on the client side. The CPU cost of the client is probably 100 times less expensive to your org.
The behavior is always the same, what I neglected to mention earlier is that since the change to ICU-UCA when the query runs on the SQL server it creates a massive (36GB) temp file, which it does not do when using BASIC collation. The query was written by one of our customers, it is essentially a full table dump of the order detail table. I have since provided him with a method to just get changed records using a LastChangeDT field, but he seems reluctant to use that and basically wants to know why it takes 30 minutes from a DB with basic collation but 3+ hours on a DB with ICU-UCA (they are identical DB's, both with the same SQL views). I have tried regenerating. the views so that if only tests the 1st element of any array, but that didn't help at all. I then removed the convert & nullif checks, leaving just pro_element("UnitQty",1,1), again no difference. Even a simple SELECT count(*) from SQL92."OrderDetail"; takes 3 seconds under BASIC, but 55 seconds under ICU-UCA.
Yes, you should share the query plan if it is dumping all the data to disk and then reading it again. That query plan is likely to be the culprit, and would probably be the most notable thing that stands out if you compared the before/after plan.
This discussion sounds like you are working with a "data engineer" of some kind. LoL. Probably wants to "Get Aaaaaaaall the Data" into parquet files on cloud storage. Data engineers are often focused on intermediate goals of their own design, rather than finding the straightest path to meet the goals of the business. It creates LOTS of X-Y problems, and you end up spending more time working on unusual things that are very indirectly related to the true needs of the business.
I would open a ticket and ask Progress if there is any way to stream this collation out of the SQL engine without going thru the temp file. That appears to be the limiting factor. It may be as simple as using more string-functions on the sever side like SUBSTRING(), TRIM(), or something like that. I have seen cases where the SQL engine is a LOT happier if you can tell it how long the character fields are in advance. I believe Progress inherited the SQL engine from another company, and after all these years, there is still friction when the SQL engine is forced to work with unlimited character fields (32K chars per CHARACTER or whatever). If you use a trick function in the query plan, it helps the SQL engine (from DataDirect/Merant) . It can treat data from OE the same way as it treated other databases back in the day (databases with normal character fields).
NOTE: We are also working on data-engineering problems. We fetch almost all our data from OE using the SQL driver. But in some cases we might start transition to using the Kafka support in ABL. Your customers may be interested in that. I haven't tried it yet but there is a new tool in databricks called "zerobus" that allows you to push raw data from a client to blob storage using a Kafka API. The data gets dropped directly into blob storage, and is managed by databricks. I do NOT think this is necessarily a better approach for the problem at hand (I agree that you should be able to get data via SQL92 as well). But it is something to consider for future customers. It would give you more flexible approach to send data to data engineers in the future without having to deal with any of their X-Y problems. Databricks and Fabric can do similar things. Fabric has a similar technology called "open mirroring" that allows you to send data-engineering data in their direction, although the big difference is that they probably don't have a Kafka interface for clients... you would drop another file format into a storage location for them to pick up.
... Hopefully some day Progress will extend their "Pro2" stuff to generate parquet blobs in the cloud (iceberg or deltalake tables). Most modern database engines support this sort of a concern, and it normally happens as an extension of CDC. But unfortunately the Progress CDC architecture is weird so I don't think Progress can build on top of it; to address this need. As I recall, the Progress CDC doesn't happen asynchronously from transaction logs, but uses some sort of native trigger that slows down every client transaction hitting the DBMS. Speaking from the perspective of a data engineer, almost nothing we do is worthy of that level of a performance hit.
We decided to just switch back to utf-8/basic, down time was only 30 minutes, and that included taking a backup, when you have exclusive use of the server you can really take advantage of all the additional parameters you can put on an index rebuild! Thanks for the advice, I've learned more about SQL that I ever wanted to.
SQL concepts are industry concepts. Don't give up.
I sometimes see people saying they'd rather use ABL "queries" to get data out of a database, and it is like saying you'd rather excavate a swimming pool with a spoon rather than a shovel.
I'd agree that there are special considerations that are specific to OE's flavor of SQL. It hasn't received any of the TLC it needs, to do things like parallel plans and fix the "SQL-LENGTH" problems and such. Still, it has major advantages over ABL "queries". It runs on native instructions, and doesn't require the launching of an "AVM" to run code in an interpreted way. If your licensing requires you to pay for OE per CPU-core, then SQL can help you squeeze a LOT more usage out of your Progress entitlements. Obviously ABL is designed to be "simple" and more accessible to entry-level programmers, but it shouldn't remain the only tool in anyone's tool belt.