This sample demonstrates a simple persistent database with the Performance Monitor enabled.
The configuration file (
xsql.cfg) looks as follows:# # Simple persistent database configuration with Performance Monitor # database_name : diskdb, database_size : 20m, cache_size : 10m, database_filename : "diskdb.dbs", # Database file name log_filename : "diskdb.log", # Transaction log file name runtime_configuration : { debug_library : false, disk_support : true, shared_memory : false, transaction_manager : mursiw }, schema : " #define uint2 unsigned<2> declare database locatedb; class Employee { string name; uint2 dept_no; unique tree<name> Iname; tree<dept_no> Idept; }; ", db_params: { mem_page_size : 512, disk_page_size : 8192 }, sql_trace : false, sql_port : 5500, sql_statements: "INSERT INTO Employee(name, dept_no) VALUES (['Luke Skywalker', 'Han Solo', 'Darth Vader'], [1,1,2]);", perfmon : { # In-memory database size for Performance Monitor database_size : 256m }, # REST interface enables connection from xPanel and monitoring applications rest: { addr : "0.0.0.0", port : 8083 } # Trace output can also be viewed in xPanel when enabled #trace_params: { # file: "xsql-trace.log" #}Note that the
schemasection defines the database using inline DDL, and thesql_statementssection specifies SQL commands to be executed automatically after the database is created.To run this sample, navigate to the
samples/xsql/configs/perfmondirectory and execute:../../../target/bin/xsql -c xsql.cfg -iOnce xSQL starts in interactive mode, you can execute SQL statements. For example:
XSQL> SELECT * FROM Employee; name dept_no ------------------------------------------------------------------------------ Darth Vader 2 Han Solo 1 Luke Skywalker 1 Selected records: 3You can also connect to the xSQL server via its REST interface using the xPanel application. To do so, create a new connector in xPanel with address
127.0.0.1and port8083. In the left panel, select the Performance Monitor module and click on your xSQL server in the connection list.