用Java開發VoltDB程式

jieforest發表於2012-10-12
Editor's Note: This post was originally authored by Andrew Wilson from the VoltDB blog.

NewSQL and NoSQL databases present developers with a new and interesting programming model where there are fewer connections to the database, query parallelism, partitions and an easy model for supporting new clusters. Last month I presented a webinar introducing the basics of application development using VoltDB. We had a lot of great questions and I thought it would be handy to write them up and share the answers with everyone.

Q: Can you address how you would handle joining tables that have different partition keys?  Would you not partition the tables in that case?
A:  For multi-partition queries you join replicated tables and partitioned tables, and you can join two or more partitioned tables but they have to be joined on all table’s partition key.

If the query has a where clause that limits the query to a single partition, it can be executed as a single partition query.  For single partition queries, you can join any combination of replicated and partitioned tables.

In all cases, consider joining on columns supported by indices (so that they are fast).

There are a number of factors to consider when joining tables in general sense.  Should the table be a replicated table, thus local to every partition, or is it too large?   For example, I may have a “users” table that contains thousands of users. I may need to map those users to a role and there may be only seven or eight roles within this “roles” table. In this case, it is safe to partition the “users” table and to replicate the “roles” table.

Consider though if your “users” table was joining with an “orders” table. This “orders” table may have thousands or millions of rows, making it a poor candidate for replication. Further, because of business rules it may be necessary to partition the orders on something other than the user but instead on the order ID.  A join in this circumstance would result in a multi-partition query.



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/301743/viewspace-746276/,如需轉載,請註明出處,否則將追究法律責任。

相關文章