Ignite: QuerySqlField - index question

classic Classic list List threaded Threaded
2 messages Options
M Singh M Singh
Reply | Threaded
Open this post in threaded view
|

Ignite: QuerySqlField - index question

Hi Folks:

A newbie question - I believe using QuerySqlField annotation exposes a field for queries.  If a field does not have the annotation we won't be able to query it.  But I am not sure what is the purpose and implication of using with and without an index parameter ?  Here is an example snippet from documentation :

/** Person ID (indexed). */
  @QuerySqlField(index = true)
  private long id;

  /** First name (not-indexed). */
  @QuerySqlField
  private String firstName;

How does it work internally, ie, how does it change storage, location, query processing ?  What are the types of fields we can index ?

Thanks




Denis Magda Denis Magda
Reply | Threaded
Open this post in threaded view
|

Re: Ignite: QuerySqlField - index question

Hi,

Yes, your initial understanding is absolutely correct: if a field is not exposed as QuerySqlField then you won’t be able to use it in both “SELECT” and “WHERE” clauses of a query. When a field is used in the “WHERE” clause (“select … where myField = 10”) then it makes sense to make it an indexed field (index=true) especially if data set is significant. Indexes allow to complete queries in O(logn) time. Without indexes a full scan will happen that corresponds to O(n) running time complexity.

You can index all the primitives and your custom objets. However there is no sense trying to index map, arrays, collections because indexing capabilities are not supported for them.

Denis

On Jun 11, 2016, at 1:47 PM, M Singh <[hidden email]> wrote:

Hi Folks:

A newbie question - I believe using QuerySqlField annotation exposes a field for queries.  If a field does not have the annotation we won't be able to query it.  But I am not sure what is the purpose and implication of using with and without an index parameter ?  Here is an example snippet from documentation :

/** Person ID (indexed). */
  @QuerySqlField(index = true)
  private long id;

  /** First name (not-indexed). */
  @QuerySqlField
  private String firstName;

How does it work internally, ie, how does it change storage, location, query processing ?  What are the types of fields we can index ?

Thanks