, , ,

Validating Application Performance in a cloud environment, using C#, Hangfire, and RethinkDB

The rise of “platform” sites (e.g. Heroku) enables developers to build and deploy web applications cheaply, without understanding operational problems. Typically these products let you purchase a combination of three things: web servers, databases, and background job execution. This typically works well, as long as you stay within their platform, and as long as their […]

Computing Absolute Values in RethinkDB

It took me a bit to figure out how to do absolute values in RethinkDB, because you can’t use conditionals and mathematical operations that you might normally expect. I expect that abs will be added to the language relatively soon, based on the outstanding tickets, but if you need it now, here is how to […]

Using multiple aggregates (SUM, COUNT, AVG) in a RethinkDB query

With a RethinkDB query, you can’t do “count” and “sum” quite the same as you’d do in SQL. Since it uses a map-reduce style engine underneath, you set count to “1” on each of your rows and then add these up later: r.db(’performance’) .table(’query_timings’) .pluck(’DbId’) .group(’DbId’) .map(function(row) { return { DbId: row(’DbId’), Duration: row(’Duration’), count: […]

RethinkDB: Truncate table

Like most relational databases, RethinkDB has several different commands to delete records from a database. To test the behavior, I made several copies of an existing table I had, which took ~1 minute per: r.db(’performance’) .tableCreate(’query_timings2’)   r.db(’performance’) .table(’query_timings2’) .insert(r.db(’performance’) .table(’query_timings’)) Currently, the SQL to ReQL comparision guide lists this as the equivalent of “truncate”: […]

Writing a “count distinct” query in RethinkDB

Writing queries to compute aggregates in RethinkDB is fairly simple; not so for “count distinct” style queries. For this example we want to write a ReQL query that looks like this: SELECT COUNT(DISTINCT IP), DbID FROM logs; The first step is to group the data by your aggregation field, and add a tracking object. We’ll […]

RethinkDB WHERE clause examples

RethinkDB calls a WHERE clause “filter”, and you can write it in several forms. One is the “equals” form: r.db(’performance’) .table(’query_timings’) .filter({ ‘Duration’: 0 }) If you can actually use this form, you can put many filters in the one function call, although they are all equality comparisons, so they aren’t that useful: r.db(’performance’) .table(’query_timings’) […]

,

Liquibase autoIncrement startWith example

Liquibase doesn’t seem to have a command line option to let you set the start points on autoIncrement fields when you generate patches, but you can fix this easily by adding “startWith” after the fact (useful for a database migration): <changeSet author="gary" id="1437853066645-52"> <createTable tableName="messages"> <column autoIncrement="true" startWith="150000" name="Id" type="bigint"> <constraints primaryKey="true" primaryKeyName="pk_messages"> </column> </createTable> […]

, , ,

Comparing two SQL Server databases with Liquibase

Liquibase is a tool for managing database schemas (e.g. diffing schemas and writing migration scripts), and supports most major commercial and open-source relational databases. I’ll show how to use it to compare a migrated database to the original database, to find and fix discrepancies. To use it with SQL Server, you’ll first need to download […]

RethinkDB “IS NULL” in a where clause filter

I find the syntax for RethinkDB filtering a little unintuitive – if this was actually Javascript, you might expect to see “row[‘Query’]”. I expect this allows them to instrument the queries more easily, although considering they are supposedly translating this into an intermediate language, this doesn’t seem necessary. To do equality, non-equality, and so on, […]