English 中文(简体)
亚洲开发银行数据分类的预测和组合?
原标题:Pros and cons of sorting data in DB?

让我假设,我有一个表格,介绍VARCHAR的类型。 我需要从这个表格中获取按该领域分类的数据。

什么最佳方法(绩效):将<条码>按外地添加到结构中,或者在数据已经过时时加以分类?

使用 Java的Im(有Hibernate),但我可以告诉有关亚洲开发银行发动机的任何情况。 它可以是任何受欢迎的关系数据库(如MySQL或MS Sql服务器或Oracle或HSQL DB或任何其他)。

表格中的记录数量大不相同,但可以假设有5k记录。

UPD:2级藏匿的藏匿处(例如EHCache)支持分类的数据如何?

最佳回答

如果这个领域得到指数化,那么该任务中的平均非行将比 Java更有效率。 还指出,如果你只是为了纯粹的显示,通常会一劳永逸地收回所有这些浏览量,而是取回其中的一个小块,以图谋显示。 你也可以在非行一级这样做。 查阅 Java的数据将需要整个表格注入 Java记忆,你不想这样做。


http://docs.jbos.org/ E.g.

List users = session.createCriteria(User.class)
    .addOrder(Order.asc("username"))
    .setFirstResult(0) // Index of first row to be retrieved.
    .setMaxResults(10) // Amount of rows to be retrieved.
    .list();
问题回答

缺乏数据库中的数据——该数据库中数据的部分内容。 数据库发动机对这些数据的分类可能比你好。

数据库中的分类:

  1. Speed. If you have an index on the order by condition, the databasae shouldn t have to sort at all, and for maximum performance you could use a clustered index.
  2. Ease of use. An order by in the sql query is easier to write and maintain than a Java Comparator.

申请中的分类:

  1. Customizability. Maybe you want to sort by more elaborate criteria, then a custom sort in Java will be more flexible.
  2. Reproducibility. If you code for different databases, their Collating rules will probably differ. Maybe that s a problem, and you want one particular odering. In Java, you can write a Custom Collator to make sure the output from all databases is ordered the same way.

我的解决办法是按条款为打字栏和写定单设定指数。

什么最佳方法(绩效):按实地分类,在数据结构已经过时时,再加分类或分类?

页: 1

它是一个权衡问题:在客户方面进行分类,意味着对服务器的影响较小。 然而,这可能需要更多的客户资源。

如果不对外地进行指数化,为了恢复整类工作,服务器将需要做以下工作:

  1. Fetch the whole recordset
  2. Sort it
  3. Send it over the network to the client

虽然在客户方面进行分类只需要<代码>1和3(资源最少)。

如果服务器需要同时为数百名客户服务,而且客户需要整个记录单,那么,在客户方面进行分类可能更为有效。

如果对外地进行指数化,数据库可以退回该指数已经分类的数据。 然而,这将需要增加桌旁,才能进入其他领域。

而且,如果你不想要整个记录,而只是一些顶级领域(如<代码>)。 由L或SlectT TOP ...... ORDER BY整理,整个检索不必经过编辑并转过网络。 在这种情况下,在数据库方面进行订购可能更为有效。

仅5 000份记录,它实际上没有多大变化,但我对数据库进行分类;即使没有实地指数,它可能至少比以后快。

  • do you usually extract only a subset of that data ? -> a good back end design (indexing and and/or partitioning) helps you extracting that subset ordered faster; then an "order by" on the db is matter of instants.
  • tables always contain a few rows of data ? then an "order by" on the db is matter of instants

甚至如果你不 t(can)优化你的数据库,那么你(几乎)总是倾向于将这种机会留给 b。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签