From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q0TBFstT015128 for ; Sun, 29 Jan 2012 12:15:54 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlkDAKsoJU/U4xEIk2dsb2JhbABDhQupTiIBAQEBCQkLCRQDIoFyAQEEASMESwcFCwsaAiYCAlcGiA8DpxaQYYEvhw4BCQcBCwkBAgMEMIQiBAEECAIEAw4CAQaCKYEWBI0sjUSMfA X-IronPort-AV: E=Sophos;i="4.71,587,1320620400"; d="scan'208";a="141914899" Received: from moutng.kundenserver.de ([212.227.17.8]) by mail1-smtp-roc.national.inria.fr with ESMTP; 29 Jan 2012 12:15:49 +0100 Received: from office1.lan.sumadev.de (dslb-188-097-002-117.pools.arcor-ip.net [188.97.2.117]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0LupVN-1SZMF33z8L-010gvd; Sun, 29 Jan 2012 12:15:49 +0100 Received: from [192.168.0.31] (dslb-084-058-002-228.pools.arcor-ip.net [84.58.2.228]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id 84BBAC0E4B; Sun, 29 Jan 2012 12:15:48 +0100 (CET) From: Gerd Stolpmann To: Diego Olivier Fernandez Pons Cc: caml-list In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Date: Sun, 29 Jan 2012 12:15:47 +0100 Message-ID: <1327835747.19516.23.camel@samsung> Mime-Version: 1.0 X-Mailer: Evolution 2.32.2 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:Wc0cDdSFdEDkbOxMpQxyh0ItFGmAcCEK/MJSIpd0Wxo upM1nSaWh5HUwkXDAUWoz7CM0p2VduPSem3YCJ/Nixnqjhg9L+ jry8VAxxqXlzJZVkd+AggMCcRN2tUgQ86LWtXuQAlL9sO1DzXz O6qdspK758O2Z5PIKI3F9kMasLfGT11Y/cXGSwskcG74fF8L05 nFnPMwhdeJOfbumWN7+F/RddSY+9ebsjz1/ciFbF9O2NEIcChH OF1wUGK/lxMIGPttx4b4Nqg5kCrqSVSA/HlEMht+/7p/ryyw5Z C+lShf7SrdV6tpbkf2WNWCdAh8KMJIHFzOTC0ULuWhFucRF0oq De/OejH5aVpjEPg82cD15HsD4GbwNMRb6VjAtavex Subject: Re: [Caml-list] SQL engine in OCaml with client side cache Am Sonntag, den 29.01.2012, 10:56 +0100 schrieb Diego Olivier Fernandez Pons: > Caml-list, > > I need an SQL server that a web-client can query and send the results to > some JavaScript graphic package. > My problem is that the bandwidth and server power are limited and paid per > usage. > > On the other hand, the data I am working with has good properties > - read only > - client always looking at the same subset of data from "different angles" > - easy to compute a subset of data the client will work on > > For instance the database contains 5 years of sales of a company in all > their stores. Some clients will want to investigate all the products of a > given store, other will want to compare a single product on all the stores, > others the sales evolution per department per year, etc. > > Therefore I thought I could add a "cache" on the client side, meaning an > in-memory SQL database that would receive a big block of data from the > server and work on it till the client writes a query that needs some data > that is not available locally in which case it would request it from the > server, etc. I think this is not possible. SQL always needs access to the complete table for executing queries (including the complete indexes). You would have to restrict yourself to a subset of SQL where it is meaningful to define caching. For example, a viable path would be to use object-relational mappings (where range queries are usually not possible). But this is not SQL anymore... > I haven't found anything like that ready-to-use, so I was considering > reengineering existing OCaml code (database + web) and maybe compile it to > JavaScript. I have control on the client so I can afford installing an > OCaml runtime if needed albeit impractical though. As you are read-only: what about creating a dump of the whole SQL tables, and to import it into a local SQL engine like sqlite? (There are Ocaml bindings.) I don't know whether you can change the db schema, but ideally it would support to make delta dumps (i.e. get all changes since the last dump), for example by including time stamps in the rows. Another option would be to use the replication feature of many SQL servers. Basically, you would have to grab the logs (journals) of the database, and to import them locally into an SQL server of the same type. The keyword to look for is "log shipping". The nice thing is that you automatically get a delta-based replication. > Does anyone has an SQL engine written in OCaml ? I can only find bindings. This is a lot of work. I have an on-disk btree implementation, if you are interested (this is in the plasma download, projects.camlcity.org/projects/plasma.html, look into src/pkv). It is written for PlasmaFS, though, but a port to a local filesystem should not be too difficult. Gerd > Also, has anyone tested the OCaml -> JavaScript on projects with > significant computation work ? > > Diego Olivier >