MySQL Views - Когда использовать и если не для

Я добавил бы больше шага вне частного конструктора:

public class Foo {
   // non-instantiable class
   private Foo() { throw new AssertionError(); }
}

Бросок эти AssertionError предотвращает методы в том же классе от инстанцирования класса (хорошо, они могут попробовать). Это обычно не проблема, но в среде команды Вы никогда не знаете то, что кто-то сделает.

Что касается "абстрактного" ключевого слова, я заметил классы утилит, разделенные на подклассы в многочисленных экземплярах:

public class CoreUtils { ... }
public class WebUtils extends CoreUtils { ... }

public class Foo { ... WebUtils.someMethodInCoreUtils() ... }

я полагаю, что это сделано так, чтобы люди не помнили который служебный класс включать. Там какие-либо оборотные стороны к этому? Действительно ли это - антишаблон?

С уважением, LES

23
задан Community 23 May 2017 в 11:54
поделиться

2 ответа

This mysql-forum-thread about indexing views gives a lot of insight into what mysql views actually are.

Some key points:

  • A view is really nothing more than a stored select statement
  • The data of a view is the data of tables referenced by the View.
  • creating an index on a view will not work as of the current version
  • If merge algorithm is used, then indexes of underlying tables will be used.
  • The underlying indices are not visible, however. DESCRIBE on a view will show no indexed columns.
11
ответ дан 29 November 2019 в 02:36
поделиться

A view can be simply thought of as a SQL query stored permanently on the server. Whatever indices the query optimizes to will be used. In that sense, there is no difference between the SQL query or a view. It does not affect performance any more negatively than the actual SQL query. If anything, since it is stored on the server, and does not need to be evaluated at run time, it is actually faster.

It does afford you these additional advantages

  • reusability
  • a single source for optimization
13
ответ дан 29 November 2019 в 02:36
поделиться
Другие вопросы по тегам:

Похожие вопросы: