Monday, October 2, 2017

Why is Oracle query not using my index

Why is Oracle query not using my index? A cheklis

One of the most common question, when it comes to performance tuning is “Why oracle is not using my index?”. This question, together with her twin question, “Why Oracle is choosing full table scan even when the table is indexed?” cover large part of the performance tuning challenges.
Even well experienced developers and DBA’s can sometimes miss a very obvious reason causing the optimizer not to choose the expected plan. After finding myself time and time again looking for explanations for poor query performance i decided to create a small checklist that i can use to methodically check until I find the issue that is causing the optimizer not to use the index.
This is far from a complete list and the post is probably going to be constantly updated as I encounter ( ok , be reminded of) other performance killing reasons.
1) Are indexed column being changed ?
For example, the index will be used only if the value of the index is not changed in the where clause. Therefore, every manipulation on the “left side” of the where clause will prevent the index from being used. In order to check this you can add the /*+ INDEX(a, i_empno) */ hint if you can not see it being used in the explain plan then there is something in the query that prevent it from being used.
2) Are you using NOT? 
The optimizer will not use the index if the query is based on the indexed columns and it contains NOT EQUAL and NOT IN.
3) Are you using LIKE (‘%% ‘) ?
if you use wildcard query with “%” in front of the string, the column index is not being used and a full table scan is required since the % can be replaces by any string. Therefore the optimizer needs to search the contents of every row of that field.
4) Are you using IS (NOT) NULL ?– Null values are not included in the index. However, this could be worked around by using nvl when creating the index (function based index), adding the PK to the index or even adding a constant to the column: create index emp_dob_idx on emp (date_of_birth,1)
5) Are you using the leading columns in a concatenated index? 
remember to put the column with the highest unique values first to make the result set smaller.
6) Are you selecting from a view?
Make sure that that the base tables have appropriate indexes
7) Are the statistics relevant and valid? 
8) Does the index exists as all ? 
you will be surprised how many times this is the problem
9) Is the query expected to return large portion of the table? 
In this case the optimizer will prefer a full scan
10) If you are using subquery you must use only IN or = (you can workaround this by changing it to a join or a function )
11) Did you do a lot of changes on the table recently?
A large number of dml operations on the table might cause the statistics to become stale and stop using the index
12) It is possible that the data on the table is skewed?
The optimizer might expect normal distribution of values between the maximum and minimum values and might choose a wrong plan if this is not the case. For example, using 01/01/0001 or 31/12/4000 as a null values might confuse the optimizer
13) Does your query actually trying to use the index?
is the where clause contains the indexed column?
14) High degree of parallelism. High degree of parallelism skews the optimizer toward full table scans. select DEGREE from dba_tables where table_name='table-name' and owner='owner-name';
15) A full scan will be cheaper than using an index if the table is small.
16) Does it use Other indexes? 
You may have other indexes that Oracle perceives as being “better” for the query.
17) Are you implicitly casting types?
Oracle sometimes cast implicitly. For example it might cast varchar2 to number when if the actual values allow (also for dates)
While it might work for a query, it will not use an index when you are joining a table on fields with different types.
18) Wrong Parameters:
optimizer_index_cost_adj – low value reduce the price of indexes use
all_rows access method – The first_rows optimizer mode is more likely to use an index than the all_rows mode.
Bonus advice:
Add the /*+ INDEX(a, col-name) */ hint. if you still can not see the index being used in the explain plan then there is something in the query that prevent it from being used.
Add the /*+ RULE */ hint. If the query uses the index with a RULE hint, you know that the problem is related to the cost-based optimizer (CBO)

Wednesday, August 30, 2017

Funny Videos 2017 | funny vines | funny baby videos | funny moments | fu...

Funny Videos 2017 | funny vines | funny baby videos | funny moments | fu...

dehleez pe mere dil ki | tere sang yaara video | way changa nai o kita |...

Dubai Roads| Dubai Metro | Dubai Nights | Dubai Night club | Dubai Laws

Funny Videos 2017 | funny vines | funny baby videos | funny moments | fu...

english hindi remix songs 2017 | english song | english songs 2017 | eng...

english hindi remix songs 2017 | english song | english songs 2017 | eng...

Punjabi Funny Jokes | Hindi funny jokes | punjabi latifay video | punjab...

Football Funny Clip | football funny moments | football skills | footbal...

english hindi remix songs 2017 | english song | english song 2017 | engl...

english hindi remix songs 2017 | english song | english song 2017 | engl...

Remix english songs 2017 hits | Remix of English Punjab Russian Songs | ...

huzoor aisa koi intezam ho jaye | huzoor aisa koi intezam ho jaye syed f...

huzoor aisa koi intezam ho jaye | huzoor aisa koi intezam ho jaye syed f...

english songs 2017 new | english songs 2017 hits | english songs remix |...

Dubai Global Village | global village rides | global village haunted hou...

latest english songs 2017 | english songs 2017 new | english songs 2017 ...

English songs 2017 new | new english songs 2017 | Most popular English S...

New English songs | english dance songs | latest english songs 2017 | en...

Monday, August 14, 2017

Mobile games | Road in Mountains | Truck and car race | Truck Driver Tru...

Car race | Car running in Mountains | Bar Truck Race | Racing Truck | R...

Racing games | Truck Car Game | Need For Speed | Racing Game | Latest Ro...

Go namaz go viral clip | go namaz go by shahzad sharif

Rocking range | viral dance | best of besy| body shape

Song of the day | Song of 2017 | dance of day | Gali Gali main shor hai

pakistan National symbols | Pak National Symbol | 14 Aug 1947 | History ...

Little girl reading Darood sharif | Allah Huma Salay Ala | Small girl re...

Little baby girl praying | Little girl pray | Darood Sharif By Small girl |

Tuesday, August 8, 2017

Gradle Vs Maven

Both are used for same purpose but gradle is new and fast in terms of setup and execution also developer
needs to write less code in gradle as compared to maven

Showing LapTop Screen on LED

Showing Laptop Dispaly on LED/LCD Screen
1)Right Click with mouse on destop
2)Choose Dispaly settings
3)On Display tab go to multiple displays drop down
and select duplicate these displays and apply

Monday, August 7, 2017

Preparing for JSF Application Development

Preparing for JSF Application Development

This feature is supported in the Ultimate edition only.
To prepare for JSF application development, you should:
  • Make sure that the Java EE: Java Server Faces plugin is enabled. This plugin is bundled with the IDE and enabled by default. However, you may have disabled it for some reason by now.
  • Create a project or module with JSF support enabled, or enable JSF support in an existing module.
On this page:

Making sure that the Java Server Faces plugin is enabled

  1. Open the Settings dialog (e.g. Ctrl+Alt+S).
  2. In the left-hand part of the dialog, select Plugins.
  3. In the right-hand part of the dialog, on the Plugins page, type faces in the search box. As a result, only the plugins whose names and descriptions contain faces are shown in the list of plugins.
  4. If the check box to the right of Java EE: Java Server Faces is not selected, select it.
  5. Click OK in the Settings dialog.
  6. If suggested, restart IntelliJ IDEA.

Enabling JSF support when creating a project or module

  1. Do one of the following:
    • If you are going to create a new project: click Create New Project on the Welcome screen or select File | New | Project.
      As a result, the New Project wizard opens.
    • If you are going to add a module to an existing project: open the projectyou want to add a module to, and select File | New | Module.
      As a result, the New Module wizard opens.
  2. On the first page of the wizard, in the left-hand pane, select Java Enterprise. In the right-hand part of the page, specify the JDK to be used and select the Java EE version to be supported.
  3. If, at this step, you are ready to specify the application server you are going to deploy your application to (e.g. to test the application behavior), do so. This will result in the corresponding server-specific run/debug configurationfor your module generated automatically. Otherwise, to be able to run your application, you will have to create the run/debug configuration yourself.
    Select the server from the list or click New and select the server of interest. Then, specify the server settings:
    • For a server installed locally, specify the path to the server installation directory. (Click /help/img/idea/2017.2/browseButton.png to select the directory in the corresponding dialog.)
    • For a hosted server (Cloud Foundry or CloudBees), specify your user account details.
  4. Under Additional Libraries and Frameworks, select the Web Applicationcheck box.
    Select the version of the Servlet specification to be supported from the Versions list.
    If you want the deployment descriptor web.xml file to be created, select the Create web.xml check box.
  5. Select the JSF check box.
    If you want the configuration file faces-config.xml to be created, select the Create faces-config.xml check box.
    Select the required library option and, if necessary, specify the associated settings. You can choose to:
    • Download and use a JSF implementation library (Mojarra).
      To do that, under Libraries, select Download.
      Now, to view or modify the associated options, click Configure, and in the Downloading Options dialog that opens:
      • Select the library version.
      • Specify the library name.
      • Select the library level (global, project, or module).
      • Under Files to download, select which of the files you want to download.
      • Under Copy downloaded files to, specify the path to the destination folder. If you want to change the default path, click /help/img/idea/2017.2/browseButton.png and specify the folder location in the dialog that opens.
    • Use a JSF library IntelliJ IDEA is already aware of.
      To do that, click Use library and select the required library from the list.
      If necessary, configure the library settings (for example, change its name). This is done in the Edit Library dialog which you can open by clicking Configure.
    • Create a new library using the appropriate JAR files available on your computer.
      To do that, click Use library and then click Create. Select the required JAR files in the dialog that opens. (For multiple selection, keep the Ctrl key pressed.)
      If necessary, configure the new library (for example, change its name or level). To do that, click Configure and specify the required settings in the Create Library dialog.
    • Postpone setting up the library until a later time. In this case, select Set up library later.
  6. If you are going to use a JSF component library or libraries (e.g. PrimeFaces, RichFaces, etc.), select the corresponding check box or check boxes and specify the associated options. The procedure is similar to that for the JSF implementation library.
    Click Next.
  7. Specify the name and location settings. For more information, see Project Name and Location or Module Name and Location.
    Click Finish.
As a result, your new module will contain:
  • The web and WEB-INF directories.
  • The file index.xhtml in the web directory. With minor modifications, you can use this file as a starting page of your application.
  • In the WEB-INF directory, if specified:
    • web.xml, the Web application deployment descriptor.
    • faces-config.xml, the JSF configuration file.
    jsf_module_structure.png
  • If specified, the JSF library or libraries included in the module dependencies.
  • An artifact specification for you module.
  • If you have specified the server, a run/debug configuration for running your application in the context of that server.

Enabling JSF support for an existing module

  1. Open the Project tool window (e.g. View | Tool Windows | Project).
  2. Right-click the module and select Add Framework Support.
  3. In the left-hand pane of the Add Frameworks Support dialog, select the Web Application check box.
    In the right-hand part of the dialog, select the version of the Servlet specification to be supported from the Versions list.
    If you want the deployment descriptor web.xml file to be created, select the Create web.xml check box.
  4. Select the JSF check box.
    If you want the configuration file faces-config.xml to be created, select the Create faces-config.xml check box.
    Select the required library option and, if necessary, specify the associated settings. You can choose to:
    • Download and use a JSF implementation library (Mojarra).
      To do that, under Libraries, select Download.
      Now, to view or modify the associated options, click Configure, and in the Downloading Options dialog that opens:
      • Select the library version.
      • Specify the library name.
      • Select the library level (global, project, or module).
      • Under Files to download, select which of the files you want to download.
      • Under Copy downloaded files to, specify the path to the destination folder. If you want to change the default path, click /help/img/idea/2017.2/browseButton.png and specify the folder location in the dialog that opens.
    • Use a JSF library IntelliJ IDEA is already aware of.
      To do that, click Use library and select the required library from the list.
      If necessary, configure the library settings (for example, change its name). This is done in the Edit Library dialog which you can open by clicking Configure.
    • Create a new library using the appropriate JAR files available on your computer.
      To do that, click Use library and then click Create. Select the required JAR files in the dialog that opens. (For multiple selection, keep the Ctrl key pressed.)
      If necessary, configure the new library (for example, change its name or level). To do that, click Configure and specify the required settings in the Create Library dialog.
    • Postpone setting up the library until a later time. In this case, select Set up library later.
  5. If you are going to use a JSF component library or libraries (e.g. PrimeFaces, RichFaces, etc.), select the corresponding check box or check boxes and specify the associated options. The procedure is similar to that for the JSF implementation library.
  6. Click OK in the Add Frameworks Support dialog.

Friday, July 7, 2017

TNS Protocol adapter error while starting Oracle SQL*Plus


https://stackoverflow.com/questions/8782842/tns-protocol-adapter-error-while-starting-oracle-sqlplus

Friday, June 9, 2017

How to connect intellij with Database


To add a new database connection (called a data source in IntelliJ), open the Database window View -> Tool Windows -> Databases, then click the + sign and select Data Source and then MySQL from the sub-menu. The defaults for the MySQL connection should for a local install of MySQL.

NLS_LANG Settings in MS-DOS Mode and Batch Mode

NLS_LANG Settings in MS-DOS Mode and Batch Mode

When using Oracle utilities such as SQL*Plus, SQL Loader, Import, and Export in MS-DOS mode, the character set field of the NLS_LANG parameter for the session must first be set to the correct value.
This is required because MS-DOS mode uses, with a few exceptions, a different character set (or code-page), for example, OEM code-page, from Windows (ANSI code-page), and the default Oracle home NLS_LANG parameter in the registry is always set to the appropriate Windows code-page. If the NLS_LANG parameter for the MS-DOS mode session is not set appropriately, error messages and data can be corrupted due to incorrect character set conversion.
For Japanese, Korean, Simplified Chinese, and Traditional Chinese, the OEM code-page is identical to the ANSI code-page. In this case, there is no need to set the NLS_LANG in MS-DOS mode.
Similarly, in batch mode, set the correct character set value of the NLS_LANG by inserting a SET NLS_LANG command at the start of the batch procedure, according to the character set of the files to be processed in the procedure.
The following table lists the Oracle character sets that correspond to the OEM primary code-page in MS-DOS mode for each of the supported languages:


Language 

Character Set 

Arabic 

AR8ASMO8X 

Brazilian Portuguese 

WE8PC850 

Catalan  

WE8PC850 

Czech  

EE8PC852  

Danish  

WE8PC850  

Dutch  

WE8PC850  

English  

US8PC437 

Finnish  

WE8PC850  

French 

WE8PC850  

German 

WE8PC850  

Greek 

EL8PC737  

Hungarian 

EE8PC852  

Italian 

WE8PC850 

Japanese 

JA16SJIS 

Korean 

KO16KSC5601 

Latin American Spanish 

WE8PC850 

Norwegian 

WE8PC850  

Polish 

EE8PC852  

Portuguese  

WE8PC850 

Romanian 

EE8PC852  

Russian 

RU8PC866  

Simplified Chinese 

ZHS16GBK 

Slovak  

EE8PC852  

Slovenian  

EE8PC852 

Spanish 

WE8PC850  

Swedish 

WE8PC850  

Traditional Chinese 

ZHT16BIG5 

Turkish 

TR8PC857