java db 程序_用Java开发VoltDB程序

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/,如需转载,请注明出处,否则将追究法律责任。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值