AgileApps Support Wiki Pre Release

Difference between revisions of "Indexes"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
 
(64 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''Designer > Data > Objects > {object} > Indexes'''
'''[[File:GearIcon.png]] > Customization > Objects > {object} > Indexes'''


Indexes are used to rapidly access database information. Once an index is supplied, the database can go directly to the record and retrieve it.
An index improves the speed of data retrieval operations on an object. Indexes can be created using one or more columns and can also be used to enforce uniqueness of records.


==About Indexes==
==About Indexes==
Indexes are used in several ways, to:
{{permissionRef|Customize Objects|create and modify Indexes in Objects}}
*'''Prevent Duplicate Record Creation''': When you add a new record or import a batch of new records, a '''Unique Index Key''' is used to identify existing records in the database and will prevent duplicates from being created
*'''Streamline Data Searches''': When you create an '''Index Key''' for an [[Objects|Object]], your searches run faster


{{permissions|Customize Objects|create and modify Indexes in Objects}}
In addition to speeding up data retrieval, indexes can be used to:
:;Prevent Duplicate Records: When you define a ''Unique Key'', a record that has the same key-field values as an existing record cannot be added to the database.
:::* A unique index cannot be created for a [[Child Object]].
:::* To see the parent object, go to '''[[File:GearIcon.png]] > Objects > {object} > Object Properties''' and inspect the '''Parent Object''' field.
 
:;Streamline Data Searches: When you create a (non-unique) '''Index Key''' for an [[Objects|Object]], you can make searches run faster by selecting records with a particular key (or set of keys). That way, you pare down the data set to minimize the number of records that are actually searched. And since the keys are typically sorted, they can be accessed more rapidly than random records.
:::* Speed is improved when the fields specified for the search/filter match one or more of the initial index fields, and they are in the same order.
:::* So if fields A, B, and C are used for an index, speed is improved for any search or filter on field A, or fields A and B (in that order)
 
;Considerations:
:* The '''[Edit]''' button appears only when the ''Use in Import For Record Merging'' option is present, as that is the only option that can be modified.
::* It is not present for an index on a [[Child Object]].
::* It is not present for an index that uses one of the [[Standard Fields]]. For example, <tt>owner_id</tt>. (Those aren't fields that would ever be used for an import merge. But when the '''[Edit]''' button is missing, now you know why.)


==How It Works==
==How It Works==


You select up to three fields in an object, which are combined to create an index key.
An ''index key'' uniquely identifies a record. In effect, it defines an address for that record. Once the system has that address, it can go straight to the record.
 
If you are looking for a friend in a city, one option is to go door to door looking for that person. That process is analogous to a search. Searches are thorough, and they're great when you want to retrieve a collection of records. But they're not very efficient.


[[Image:addindex.gif|thumb]]
Another option is to go the phone book, and find your friend's address. The phone book is an ''index''. The person's name is the ''key'' you use to look up their address. And once you have their address, you can go straight to your friend's house.


===Choosing Fields for Indexes===
===Choosing Fields for Indexes===


Most [[Field Types|field types]] are available for use as components in an index, with the following exceptions - these field types '''are not eligible''' as components in an index:
You can select up to ten fields in an object, which are combined to create an index key. You can also choose the [[Record Identifier]] (aka "record name") as the index key.


*Multiline text
{{Tip|Use a maximum of three or four fields, for greatest efficiency.}}
*Rich text area
 
*File
Most [[Field Types|field types]] are available for use as components in an index, with the following exceptions - these field types '''are ''not'' eligible''' as components in an index:
*Image
 
*Custom components
:*Text Area
:*Rich text area
:*File
:*Image
:*Multi Object Lookup


===Guidelines===
===Guidelines===
*You can create multiple index keys for an object.
:*You can create multiple index keys for an object.
*Any regular Index Key can be selected as a Unique Index Key.
:*Any regular Index Key can be selected as a Unique Key.
*Multiple Unique Index Keys can be created.
:*The collection of values in an Index Key may contain duplicates. The collection of values in a Unique Key cannot.
*Each index key in a Unique Index Key must be a unique value.
:*Multiple Unique Keys can be created.
*After an index is created, only the Unique Key checkbox can be modified. The selected fields cannot be changed. (The key cannot be edited. A new index field can be created, instead.)
:*After an index is created, only the Unique Key checkbox can be modified. The selected fields cannot be changed. (The key cannot be edited. A new index field can be created, instead.)
*The sum of the length (maximum storage length) of the fields selected for the index cannot exceed 1024 bytes.
:*The sum of the length (maximum storage length) of the fields selected for the index cannot exceed 1024 bytes.


Choosing fields for index keys takes some consideration.  
Choosing fields for index keys takes some consideration.  
Line 38: Line 54:
'''Index Keys:'''  
'''Index Keys:'''  
You should select fields that distinguish the record from others in the database, and choose to combine typical "demographic" fields. For example:
You should select fields that distinguish the record from others in the database, and choose to combine typical "demographic" fields. For example:
:<syntaxhighlight lang="java" enclose="div">
  City
  City
  State
  State
  Industry+Zip Code
  Industry+Zip Code
  Product+State
  Product+State
Opportunity+Close Date
  URL
  URL
</syntaxhighlight>


'''Unique Index Keys:'''  
'''Unique Keys:'''  
Because the resulting value must be unique, generic "demographic" fields are generally not suitable. The following list includes the kinds of field combinations you should consider for a Unique Index Key:
Because the resulting value must be unique, generic "demographic" fields are generally not suitable. The following list includes the kinds of field combinations you should consider for a Unique Index Key:
:<syntaxhighlight lang="java" enclose="div">
  Email Address
  Email Address
  Contact Name+Product+Date Purchased
  Contact Name+Product+Date Purchased
  Account Number
  Account Number
</syntaxhighlight>


===Caution===
===Effects of Operations===
 
;Creating a new index on existing data:If you create a new unique index on existing data and the data has no duplicate entries of the combination of fields, then it will give message “Index created successfully”
:If you create a new unique index on an existing data and the data has duplicate entries of the combination of fields, then an index will be created which acts for only future additions or updates
 
;Adding new record to the object:If there is no existing record with same values for fields selected in the unique index, then the record will be added successfully.
:If there is an existing record with same values for fields selected in the unique index, then it will give message “Operation results in unique index violation ”


;Updating a record:If there exists another record with values to be updated for fields selected in the unique index of the current record, then it will give message “Operation results in unique index violation ".
;Creating a new Unique Key index on existing data:
:If there exists no reord with the updated fields for the unique index fields, then the record is updated successfully.
:*If the data has no duplicate entries for that combination of fields, the index is created successfully.
:*If the data has duplicate entries for that combination of fields, index creation fails.
:*The check for duplicate entries ''includes'' entries in the [[Recycle Bin]], since they could be restored at a later date.


;Deleting a record:The delete operation will be successfull even if there is an index applied.
;Adding a new record to an object with a Unique Key index:
:*If no existing record has the same values for the fields that make up the unique index, the record is added successfully.
:*If there is an existing record with the same values for those fields, an error occurs.


;Restoring a record:If there exists another record with the same values for index fields (that is not part of recycle bin) then it will give a message "Operation results in unique index violation". Otherwise, the operation will be successful.
;Updating a record to change Unique Key values:
:*If no other record exists with those values, the update succeeds.
:*If another record exists with those values, the update fails.


;Adding Index to an Object:The addition of unique index to an object will not check for the uniqueness of existing records.
;Deleting a record:When a record is deleted, corresponding index entries are deleted, as well.


==Working with Indexes==
==Working with Indexes==
===Add an Index===
===Create an Index===
#Click '''Designer > Data > Objects > {object}'''
#Click '''[[File:GearIcon.png]] > Customization > Objects > {object}'''
#Click the Index tab
#Click the '''Indexes''' tab
#Click the [Add Index] button to add an index, and add this information:
#Click the '''[New Index]''' button to add an index, and add this information:
#;Name:Name is a Text field. Name takes only alphanumeric characters, and underscore.
#;Name:Name is a Text field. Name takes only alphanumeric characters, and underscore.
#;Enable Unique Key:Enable unique Key is a check box. Check this box if you need to make the combination of selected fields unique.
#::
#;Enable Unique Key:Check this box to ensure that the combination of selected fields is unique for every record in the object.
#::<span id="primary_key"></span>
#;Use in Import for Record Merging (Primary Key):When multiple Unique Key indexes exist, this selection determines which one is used to update records during an [[Import Data|Import]].
#::
#:For example, if <tt>company_name</tt> is a unique key, and you import a record for "ABC Co.", that information in the imported record updates the "ABC Co." record, if one exists. Otherwise, a new record is added. You can use that feature to merge information from multiple spreadsheets into one object--as for example when one spreadsheet has company names and addresses, while another has company names and credit terms.
#::
#;Select Fields to be used in Index:This contains two combo boxes. Move one or more fields from left combo box to right combo box. The items in the right combo box will be used to create the index.
#;Select Fields to be used in Index:This contains two combo boxes. Move one or more fields from left combo box to right combo box. The items in the right combo box will be used to create the index.
#Click the [Save] Button to create the index with given values
#::
#Click '''[Save]''' to create the index


===Delete an Index===
===Delete an Index===
To delete an existing index:
To delete an existing index:
#Click '''Designer > Data & Presentation > Objects > {object}'''
#Click '''[[File:GearIcon.png]] > Customization > Objects > {object} > Indexes > {index}'''
#Click the Index tab
#Click '''[Delete]'''
#Click the [Delete] button
<noinclude>
<noinclude>


[[Category:{{features}}]]
[[Category:Object Aspects]]
[[Category:Objects| 6]]
[[Category:Glossary]]
</noinclude>
</noinclude>

Latest revision as of 06:37, 21 October 2016

GearIcon.png > Customization > Objects > {object} > Indexes

An index improves the speed of data retrieval operations on an object. Indexes can be created using one or more columns and can also be used to enforce uniqueness of records.

About Indexes

Lock-tiny.gif

Users that have the Customize Objects permission can create and modify Indexes in Objects. 

In addition to speeding up data retrieval, indexes can be used to:

Prevent Duplicate Records
When you define a Unique Key, a record that has the same key-field values as an existing record cannot be added to the database.
  • A unique index cannot be created for a Child Object.
  • To see the parent object, go to GearIcon.png > Objects > {object} > Object Properties and inspect the Parent Object field.
Streamline Data Searches
When you create a (non-unique) Index Key for an Object, you can make searches run faster by selecting records with a particular key (or set of keys). That way, you pare down the data set to minimize the number of records that are actually searched. And since the keys are typically sorted, they can be accessed more rapidly than random records.
  • Speed is improved when the fields specified for the search/filter match one or more of the initial index fields, and they are in the same order.
  • So if fields A, B, and C are used for an index, speed is improved for any search or filter on field A, or fields A and B (in that order)
Considerations
  • The [Edit] button appears only when the Use in Import For Record Merging option is present, as that is the only option that can be modified.
  • It is not present for an index on a Child Object.
  • It is not present for an index that uses one of the Standard Fields. For example, owner_id. (Those aren't fields that would ever be used for an import merge. But when the [Edit] button is missing, now you know why.)

How It Works

An index key uniquely identifies a record. In effect, it defines an address for that record. Once the system has that address, it can go straight to the record.

If you are looking for a friend in a city, one option is to go door to door looking for that person. That process is analogous to a search. Searches are thorough, and they're great when you want to retrieve a collection of records. But they're not very efficient.

Another option is to go the phone book, and find your friend's address. The phone book is an index. The person's name is the key you use to look up their address. And once you have their address, you can go straight to your friend's house.

Choosing Fields for Indexes

You can select up to ten fields in an object, which are combined to create an index key. You can also choose the Record Identifier (aka "record name") as the index key.

Thumbsup.gif

Tip: Use a maximum of three or four fields, for greatest efficiency.

Most field types are available for use as components in an index, with the following exceptions - these field types are not eligible as components in an index:

  • Text Area
  • Rich text area
  • File
  • Image
  • Multi Object Lookup

Guidelines

  • You can create multiple index keys for an object.
  • Any regular Index Key can be selected as a Unique Key.
  • The collection of values in an Index Key may contain duplicates. The collection of values in a Unique Key cannot.
  • Multiple Unique Keys can be created.
  • After an index is created, only the Unique Key checkbox can be modified. The selected fields cannot be changed. (The key cannot be edited. A new index field can be created, instead.)
  • The sum of the length (maximum storage length) of the fields selected for the index cannot exceed 1024 bytes.

Choosing fields for index keys takes some consideration.

Index Keys: You should select fields that distinguish the record from others in the database, and choose to combine typical "demographic" fields. For example:

 City
 State
 Industry+Zip Code
 Product+State
 URL

Unique Keys: Because the resulting value must be unique, generic "demographic" fields are generally not suitable. The following list includes the kinds of field combinations you should consider for a Unique Index Key:

 Email Address
 Contact Name+Product+Date Purchased
 Account Number

Effects of Operations

Creating a new Unique Key index on existing data
  • If the data has no duplicate entries for that combination of fields, the index is created successfully.
  • If the data has duplicate entries for that combination of fields, index creation fails.
  • The check for duplicate entries includes entries in the Recycle Bin, since they could be restored at a later date.
Adding a new record to an object with a Unique Key index
  • If no existing record has the same values for the fields that make up the unique index, the record is added successfully.
  • If there is an existing record with the same values for those fields, an error occurs.
Updating a record to change Unique Key values
  • If no other record exists with those values, the update succeeds.
  • If another record exists with those values, the update fails.
Deleting a record
When a record is deleted, corresponding index entries are deleted, as well.

Working with Indexes

Create an Index

  1. Click GearIcon.png > Customization > Objects > {object}
  2. Click the Indexes tab
  3. Click the [New Index] button to add an index, and add this information:
    Name
    Name is a Text field. Name takes only alphanumeric characters, and underscore.
    Enable Unique Key
    Check this box to ensure that the combination of selected fields is unique for every record in the object.
    Use in Import for Record Merging (Primary Key)
    When multiple Unique Key indexes exist, this selection determines which one is used to update records during an Import.
    For example, if company_name is a unique key, and you import a record for "ABC Co.", that information in the imported record updates the "ABC Co." record, if one exists. Otherwise, a new record is added. You can use that feature to merge information from multiple spreadsheets into one object--as for example when one spreadsheet has company names and addresses, while another has company names and credit terms.
    Select Fields to be used in Index
    This contains two combo boxes. Move one or more fields from left combo box to right combo box. The items in the right combo box will be used to create the index.
  4. Click [Save] to create the index

Delete an Index

To delete an existing index:

  1. Click GearIcon.png > Customization > Objects > {object} > Indexes > {index}
  2. Click [Delete]