It's not surprising that it's N times faster than ORACLE, such lightweight is the king
Tags: oracle, sql, olap, database
Published: 2023-11-25 23:41:20

Oracle is a widely used database, and it is not a professional analytical database. When the data volume is large, it often results in poor computational performance, which affects the user experience. Nowadays, there are many new analytical databases that are faster or even far superior in performance than Oracle. So when Oracle performance is insufficient, replacing to these databases seems to solve the problem.

The matter is not so simple.

Firstly, these new databases generally cannot completely replace Oracle. Oracle is not only used for OLAP, but also for OLTP, and these faster analysis databases do not have the ability of OLTP (new databases that support OLTP, including HTAP advocates, may not run faster than Oracle without the help of larger clusters). Therefore, the new database has to coexist with Oracle, and there are two databases as a result.

To say the least, even if the current Oracle is only used for OLAP, it may not be completely replaced. Oracle’s support for complex SQL is quite good, and optimization is also done well. The main reason for its slow performance is that it also needs to support OLTP and cannot use columnar storage. If these new databases cannot take advantage of columnar storage (most of the columns in the entire table need to be referenced), and face many complex SQL statements, due to insufficient optimization experience, they may not be able to run as well as Oracle under the same hardware resources, and often need to rely on clusters. In addition, Oracle also has strong stored procedure functionality, which is also a capability that many new databases lack. If there are such operations in applications, Oracle still needs to be used.

Not being able to completely replace Oracle means that there need to be two sets of databases, each doing their own specialized calculations, and overall, the user experience can become better.

Going further, even if the new database can completely replace Oracle in terms of functionality and performance, there is still a migration risk issue. For businesses that are actually functioning, it is not advisable to hastily migrate them all to a new database. Generally, a gradual migration plan with two databases coexisting should also be adopted.

So, adopting a new database with better performance will almost certainly result in the phenomenon of two databases.

However, the co-existing of two databases is a very heavy thing, as the architecture becomes complex and deployment and operation are also much more troublesome, which means a sharp increase in costs. If the new database used still requires distributed deployment, it will be even heavier, even heavier than the original Oracle (most Oracle runs on a standalone machine).

There are also business issues. Oracle is typically used by high-end commercial users who will also purchase a commercial database, which is a significant cost. This type of user is also very cautious about introducing a new database and other architectural adjustments, making it difficult to scale out at any time. They often buy enough capacity for several years at a time, which causes waste in the early stage.
In short, it’s very expensive!

Is there another option?
Use lightweight esProc SPL!

esProc SPL can also easily run N times the computational performance of Oracle. The following is a test result of TPCH 100G (in seconds):
<table> 
 <thead> 
  <tr>
   <th> </th>
   <th> esProc SPL </th>
   <th> StarRocks </th>
   <th> ClickHouse </th>
   <th> Oracle </th>
  </tr> 
 </thead> 
 <tbody> 
  <tr>
   <td> q1 </td>
   <td> 9.7 </td>
   <td> 14.0 </td>
   <td> 15.4 </td>
   <td> 114.3 </td>
  </tr> 
  <tr>
   <td> q2 </td>
   <td> 1.3 </td>
   <td> 0.6 </td>
   <td> 17.3 </td>
   <td> 1.9 </td>
  </tr> 
  <tr>
   <td> q3 </td>
   <td> 8.8 </td>
   <td> 9.8 </td>
   <td> memory overflow </td>
   <td> 165.8 </td>
  </tr> 
  <tr>
   <td> q4 </td>
   <td> 4.9 </td>
   <td> 5.7 </td>
   <td> memory overflow </td>
   <td> 158.4 </td>
  </tr> 
  <tr>
   <td> q5 </td>
   <td> 8.9 </td>
   <td> 13.1 </td>
   <td> memory overflow </td>
   <td> 174.5 </td>
  </tr> 
  <tr>
   <td> q6 </td>
   <td> 4.5 </td>
   <td> 3.9 </td>
   <td> 4.8 </td>
   <td> 126.7 </td>
  </tr> 
  <tr>
   <td> q7 </td>
   <td> 10.5 </td>
   <td> 12.4 </td>
   <td> memory overflow </td>
   <td> 181.5</td>
  </tr> 
  <tr>
   <td> q8 </td>
   <td> 6.9 </td>
   <td> 8.3 </td>
   <td> memory overflow </td>
   <td> 209.7 </td>
  </tr> 
  <tr>
   <td> q9 </td>
   <td> 16.8 </td>
   <td> 21.3 </td>
   <td> memory overflow </td>
   <td> 256.0 </td>
  </tr> 
  <tr>
   <td> q10 </td>
   <td> 8.3 </td>
   <td> 11.1 </td>
   <td> 58.3 </td>
   <td> 195.6 </td>
  </tr> 
  <tr>
   <td> q11 </td>
   <td> 0.9 </td>
   <td> 1.3 </td>
   <td> 6.7 </td>
   <td> 8.7 </td>
  </tr> 
  <tr>
   <td> q12 </td>
   <td> 4.9 </td>
   <td> 4.8 </td>
   <td> 10.7 </td>
   <td> 186.0 </td>
  </tr> 
  <tr>
   <td> q13 </td>
   <td> 12.1 </td>
   <td> 21.3 </td>
   <td> 134.1 </td>
   <td> 33.3 </td>
  </tr> 
  <tr>
   <td> q14 </td>
   <td> 3.3 </td>
   <td> 4.6 </td>
   <td> 10.2 </td>
   <td> 170.0 </td>
  </tr> 
  <tr>
   <td> q15 </td>
   <td> 4.7 </td>
   <td> 7.1 </td>
   <td> 11.2 </td>
   <td> 161.8 </td>
  </tr> 
  <tr>
   <td> q16 </td>
   <td> 2.7 </td>
   <td> 2.9 </td>
   <td> 4.0 </td>
   <td> 10.8 </td>
  </tr> 
  <tr>
   <td> q17 </td>
   <td> 5.3 </td>
   <td> 4.2 </td>
   <td> 44.6 </td>
   <td> 156.5 </td>
  </tr> 
  <tr>
   <td> q18 </td>
   <td> 6.4 </td>
   <td> 20.8 </td>
   <td> memory overflow </td>
   <td> 416.8 </td>
  </tr> 
  <tr>
   <td> q19 </td>
   <td> 5.8 </td>
   <td> 6.0 </td>
   <td> &gt;600 </td>
   <td> 144.1 </td>
  </tr> 
  <tr>
   <td> q20 </td>
   <td> 5.2 </td>
   <td> 5.2 </td>
   <td> 31.2 </td>
   <td> 171.0 </td>
  </tr> 
  <tr>
   <td> q21 </td>
   <td> 11.9 </td>
   <td> 14.5 </td>
   <td> syntax error </td>
   <td> 360.7 </td>
  </tr> 
  <tr>
   <td> q22 </td>
   <td> 2.5 </td>
   <td> 1.9 </td>
   <td> 8.4 </td>
   <td> 37.7 </td>
  </tr> 
  <tr>
   <td> Total </td>
   <td> 146.3 </td>
   <td> 194.8 </td>
   <td> - </td>
   <td> 3441.8 </td>
  </tr> 
 </tbody> 
</table> 

It can be seen that because it is not a professional analytical database, Oracle’s computing performance is indeed not superior, but it has comprehensive functions and can implement all the cases. For detailed test reports, please refer to: [SPL computing performance test series: TPCH](https://c.scudata.com/article/1684805351312) .

Strictly speaking, esProc SPL is not a database, but a professional computing engine. It directly uses files to store data, supports its own columnar storage format files, and provides high-performance algorithms commonly used in modern data warehouses. This way, as long as the data is converted into files of these formats, high-performance calculations can be implemented. esProc does not have the concept of “(data)base”, which means there is no concept of loading into database and exporting out of database, as well as inside or outside a database. Data files can be stored in directories, moved freely, redundant, and even placed on the cloud, making management very free and convenient. The complexity of operation and maintenance is much lower than that of databases.

This is lightweight storage.

esProc provides a JDBC driver similar to a database for upper-level applications to call:

```
Class.forName("com.esproc.jdbc.InternalDriver");
Connection conn =DriverManager.getConnection("jdbc:esproc:local://");
Statement statement = conn.createStatement();
ResultSet result = statement.executeQuery("=T(\"Orders.btx\").select(Amount>1000 && like(Client,\"*s*\")
```
Unlike regular databases, esProc, as a pure Java program, can be seamlessly embedded into Java applications for execution. The entire computing engine is built into the JDBC driver package, unlike databases that require an independent server process. The esProc core package is less than 15MB, and with various third-party data source drivers, it is only hundreds of MBs and can even run smoothly on Android. esProc is like the code written by programmers themselves, packed into a large package, running within the same process, and enjoying the framework advantages brought by mature Java frameworks together. This is equivalent to esProc moving the computing power that was originally only available in data warehouses into the application.

This is lightweight deployment.

esProc no longer uses SQL, but has its own programming language SPL. SPL has all the computing power of SQL:
```
Orders.sort(Amount) // sorting
Orders.select(Amount*Quantity>3000 && like(Client,"*S*")) // filtering
Orders.groups(Client; sum(Amount)) // grouping
Orders.id(Client) // distict
join(Orders:o,SellerId ; Employees:e,EId) // join
...
```
For complex operations, SPL is much more convenient than SQL. For example, in this task, to calculate the longest consecutive days for a stock to rise, SQL needs to be written in multiple nested, lengthy, and difficult to understand:
```
select max(ContinuousDays) from (
    select count(*) ContinuousDays from (
        select sum(UpDownTag) over (order by TradeDate) NoRisingDays from (
            select TradeDate,case when Price>lag(price) over ( order by TradeDate)then 0 else 1 end UpDownTag from Stock ))
    group by NoRisingDays )
```
The same calculation logic is much simpler to write in SPL:
```
Stock.sort(TradeDate).group@i(Price<Price[-1]).max(~.len())
```
This is lightweight code.

Lightweight does not necessarily mean weak functionality, on the contrary, the functionality of esProc SPL is more powerful than many new databases:

SPL has comprehensive process control statements, such as for loops and if branches, and also supports subroutine calls, which implements the ability of store procedures; And many new databases have weak or even no stored procedure capabilities.

SPL supports a variety of external data sources, making it easy to perform multiple data source calculations, such as Oracle and Restful mixed calculations. Specifically, based on the cold data in files and the hot data in Oracle mixed calculations, real-time calculation and statistics can be easily achieved; Due to the closed nature of databases, mixed computing has always been a challenging problem.

SPL has richer high-performance algorithms than SQL, which can more fully utilize hardware resources. It is often possible to use a single machine to achieve the effect of a distributed data warehouse cluster, as shown in [Here comes big data technology that rivals clusters on a single machine](https://c.scudata.com/article/1698972218102)

esProc SPL also has a simple and easy-to-use development environment that provides single step execution, breakpoint setting, and WYSIWYG result preview. The development efficiency is much higher than SQL and stored procedures:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j6nhagdbjqtld5jhz7fq.png)

(Here [A programming language coding in a grid](https://c.scudata.com/article/1681713093064) is a more detailed introduction to SPL.)

Finally, esProc SPL is open source and free. It is here https://github.com/SPLWare/esProc .