This question already has answers here:
Oracle: function based index selective uniqueness
(2 answers)
Closed 8 years ago.
I have a table with a column IS_LOGGED which takes only two values 'Y' or 'N'
I want to have a Function based index on the column IS_LOGGED where value is 'Y'.
The purpose of index is to list all entries in an easy and fast to access manner.
Suppose you get a 1500 pages thick book to read with an index listing only specific chapters. What is the use of such an index?
I don't think you need a function based index here. Simply create an index and modify your queries to include IS_LOGGED = 'Y' clause.
Related
This question already has answers here:
How to select specific columns in laravel eloquent
(23 answers)
Closed 6 months ago.
This code fetches all the data in the table in the database, but I want to set a maximum limit, for example, it fetches only 4 columns from the table so that it does not load all the columns in the table
'productes' => productModel::orderBy('id', 'DESC')->get()
'productes' => productModel::orderBy('id', 'DESC')->limit(20)->get(['id',...])
Try this. But I'm highly recommended you read laravel documentation
limit is the count of rows that will be fetched from DB and
get will fetch columns that you passed in the array
This question already has an answer here:
Power BI Embed URL-multiple filters
(1 answer)
Closed 3 years ago.
I have three dimension tables.In dashboard i will be having 3 slicer/filter 1-language, 2-Mat_type, 3-PO_type.
Since they are dimension tables there are no relation. But when I select a value(Chinese) in language filter, the other 2 filters should show values Chinese values.
What if I have fact tables associated with material and PO Tables.?
I would suggest creating a true Language dimension table with three rows for your three languages. Then create relationships between it and all three of your current dimension tables (based on their Language column). That way when you select a Language (from the Language dimension), it would filter your three current dimension tables.
Here is how the relationships would look.
And in the canvas, if you have the four slicers like this...
You can make a selection in the language slicer (note that it is coming from the separate Language dimension) and the other three slicers will get filtered. I would advocate for hiding the Language field in the other three dimensions so that they don't get used accidently.
This question already has answers here:
Synchronize independent spreadsheet rows, filled by IMPORTRANGE()
(2 answers)
Closed 7 years ago.
I am looking for some advice on how to approach this, I would like to sort a spreadsheet across 2 sheets using a google script. I know how to use sort () but it only works on a single sheet. First sheet has 2 columns, student name and student number, second sheet has columns student name and student number linked from the first sheet (ex. =Sheet1!A1) and additional columns to enter student marks. Problem is if I use sort on the first sheet then the mark columns will no longer align with the student names and numbers because they are referenced from the first sheet. I know combining into 1 sheet would solve this but I need them in different sheets as it's part of a bigger project.
I could use some advice on how to approach this using a google script.
You could also use VLOOKUP in your second sheet instead of direct references. Then you can rearrange the rows in Sheet1 all you want without affecting Sheet2. e.g. =VLOOKUP(A1, Sheet1!$A$1:$B,2,false)
Place that formula into all cells in column B of the second sheet.
I'm assuming that the student name is always in column A and the student number in column B.
This question already has an answer here:
How to check if a columns value was explicitly specified in a PL/SQL BEFORE UPDATE trigger?
(1 answer)
Closed 8 years ago.
Is there an efficient method to identify which column has changed in a table in Oracle using a trigger? How to check if only one column (of interest) or all other columns also changed?
As the post Alex Pole pointed in your comments states, you could use the UPDATING function.
But you can also develop different triggers for updating specific columns with "BEFORE UPDATE OF" clause, witch is the optimal option if there is no code to share among the actions for the involved columns.
When I run the merge query then index cannot read and query is running very slow please advise me.
Index in stage_dim_accounts(rbc_code)
Index in map_rbc_etl(free_code_9)
MERGE INTO stage_dim_accounts t
USING map_rbc_etl s ON (t.rbc_code = s.free_code_9)
WHEN MATCHED THEN UPDATE
SET t.indx_no= s.indx_no
WHERE s.annexure= 'AXN-I'
AND (.free_code_9 <> 'NA' AND s.free_code_9 <> '0')
AND t.rbc_code <> 'NA'
Thanks in advance
The optimizer is smart enough to know that your indexes are useless.
An index on free_code might be useful if most of the values in that column were either '0' or 'NA'. As you haven't provided any information regarding data volumes or distribution we can't tell. But you have other restriction criteria on map_rbc_etl, so the database needs to go to the table anyway. My guess is that optimizer has chosen to use a full table scan on map_rbc_etl because that's quicker than a huge number of indexed reads.
This is because an indexed read is two operations - read the index, read the row. So it only pays dividends if the percentage of rows read is tiny. Otherwise it is just more efficient to read all the rows and winnow them in memory.
Here is the great "secret" of tuning: indexed reads are not always faster; full table scans are not always bad.
Similar logic applies to reading the stage_dim_accounts. The indexed column is unlikely to be selective. Unless ... unless the number of rows in map_rbc_etl is very small and only matches a small selection of rows in stage_dim_accounts. My previous comment on data metrics applies again.
indexes to use
on map_rbc_etl( free_code_9, annexure)
and on stage_dim_accounts(rbc_code);
now these may not be used for reasons in previous answer.
Additional reasons an index may not be used are:
1. The optimizer decides it would be more efficient not to use index.
2. if column is on view and has function call on column. To use this use function based indexes.
3. you perform mathematical operation in query. Note you can look at explain plan and create index to match how it is loading the rows.
4. you concat columns together in where clause. Use function based index for overcoming this.
5. You do not include first column in concatenated index in where clause of your statement. Note that Oracle 9i or greater do skip scanning and can use the index.
6. You use or clause. In this case it is best to create one index for all but the or clause and one for each of the or values then it will use all indexes appropriately.
if you don't know how to use function based indexes an example for a to_upper() in where clause you would use the following
create indexName on tableName(to_upper(colname));
any oracle sql function (built in or user created) can be in the index.