Oracle Performance Testing for Composite Key Using Cost

Composite Key

-- CREATE DUMMY TABLE FOR TESTING
CREATE TABLE DUMMY_TABLE1 (
  COL1 VARCHAR(100),
  COL2 VARCHAR(100),
  COL3 VARCHAR(100), 
  COL4 VARCHAR(100),
  COL5 VARCHAR(100),
  COL6 VARCHAR(100),
  COL7 VARCHAR(100),
  COL8 VARCHAR(100),
  COL9 VARCHAR(100),
  COL10 VARCHAR(100)
);

-- GENERATE DUMMY DATA
BEGIN
  FOR I IN 1..1000000
  LOOP
    INSERT INTO DUMMY_TABLE1 VALUES (I, I, I, I, I, I, I, I, I, I);
  END LOOP;
  COMMIT;
END; 
/ 

SELECT * FROM DUMMY_TABLE1 WHERE COL1 = '1';
-- COST: 3021

CREATE INDEX DUMMY_INDEX1 ON DUMMY_TABLE1 (COL1, COL2, COL3);
CREATE INDEX DNUMMY_INDEX2 ON DUMMY_TABLE1 (COL4);

-- COMPOSITE INDEX AND QUERY INCLUDING FIRST COLUMN OF THE COMPOSITE KEY
SELECT * FROM DUMMY_TABLE1 WHERE COL1 = '1';
-- COST: 819
SELECT * FROM DUMMY_TABLE1 WHERE COL1 = '1' AND COL2 = '1';
-- COST: 7
SELECT * FROM DUMMY_TABLE1 WHERE COL1 = '1' AND COL2 = '1' AND COL3 = '1'
-- COST: 4

SELECT * FROM DUMMY_TABLE1 WHERE COL2 = '1';
-- COST: 3021

SELECT * FROM DUMMY_TABLE1 WHERE COL4 = '4';
-- COST: 801

-- DROP TABLE
DROP TABLE DUMMY_TABLE1;

Conclusion

For composite index,

  • The first cols of the index must be matched in order to improve the performance.
  • For same condition, the more cols you included in composite index would reduce performance

 

 

 

 

NodeJs Hello World Project

HelloWorld Example 

main.js

/**
* nodeJS is JavaScript-based framework/platform built on Google Chrome V8 Engine.
* It is used to develop I/O intensive web application 
* like video streaming sites, sigle-page application. 
*/
var http = require("http");
http.createServer(function(request, response){
 response.writeHead(200, {'Content-Type': 'text/plain'});
 response.end('Hello World\n');
}).listen(8080);
console.log("Server is running on http://localhost:8080/");

Command to start server

node main.js

 

NPM Install Proxy

Proxy Configuration NPM Command

Npm Command to set proxy configuration.

npm config set proxy http://login:pass@host:port
npm config set https-proxy http://login:pass@host:port
npm config set http-proxy http://login:pass@host:port
npm config set registry "http://registry.npmjs.org/"
npm config set strict-ssl false

The configuration is stored in <User Folder>/.npmrc

.npmrc

proxy = http://login:pass@host:port
https-proxy = http://login:pass@host:port
strict-ssl = false
http_proxy = http://login:pass@host:port
registry = http://registry.npmjs.org/

Simple Spring Security Web Application Example – web.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
 xmlns:context="http://www.springframework.org/schema/context"
 xmlns:security="http://www.springframework.org/schema/security"
 xsi:schemaLocation="
 http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans.xsd
 http://www.springframework.org/schema/context
 http://www.springframework.org/schema/context/spring-context.xsd
 http://www.springframework.org/schema/security
 http://www.springframework.org/schema/security/spring-security.xsd">

 <context:component-scan base-package="com.ittechoffice.example.controller" />

 <!-- Spring MVC Config -->
 
 <!-- Add support of JSP -->
 <bean
 class="org.springframework.web.servlet.view.InternalResourceViewResolver">
 <property name="prefix" value="/WEB-INF/jsp/" />
 <property name="suffix" value=".jsp" />
 </bean>
 
 <!-- Spring Security Config -->
 <security:http auto-config="true">
 <!-- P.S. "**" means zero or more directories in the path -->
 <security:intercept-url pattern="/**" access="hasAuthority('ADMIN')"/>
 </security:http>
 
 <security:authentication-manager>
 <security:authentication-provider>
 <security:user-service>
 <security:user name="user" password="password" authorities="ADMIN"/>
 </security:user-service>
 </security:authentication-provider>
 </security:authentication-manager>

</beans>

 

Simple Spring Security Web Application Example – POM.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>com.ittechoffice</groupId>
 <artifactId>ItTechOfficeSpringSecurityWebExample</artifactId>
 <version>0.0.1-SNAPSHOT</version>

 <properties>
 <spring.version>4.0.1.RELEASE</spring.version>
 </properties>

 <dependencies>

 <!-- Spring Core Container -->
 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-context</artifactId>
 <version>${spring.version}</version>
 </dependency>

 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-core</artifactId>
 <version>${spring.version}</version>
 </dependency>

 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-beans</artifactId>
 <version>${spring.version}</version>
 </dependency>

 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-context-support</artifactId>
 <version>${spring.version}</version>
 </dependency>

 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-expression</artifactId>
 <version>${spring.version}</version>
 </dependency>

 <!-- Spring MVC -->
 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-web</artifactId>
 <version>${spring.version}</version>
 </dependency>

 <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-webmvc</artifactId>
 <version>${spring.version}</version>
 </dependency>

 <!-- Spring Security -->
 <dependency>
 <groupId>org.springframework.security</groupId>
 <artifactId>spring-security-core</artifactId>
 <version>${spring.version}</version>
 </dependency>

 <dependency>
 <groupId>org.springframework.security</groupId>
 <artifactId>spring-security-config</artifactId>
 <version>${spring.version}</version>
 </dependency>

 <dependency>
 <groupId>org.springframework.security</groupId>
 <artifactId>spring-security-web</artifactId>
 <version>${spring.version}</version>
 </dependency>

 </dependencies>
</project>

Simple Spring Security Web Application Example

Source Code:

https://github.com/imben1109/ittechoffice-example/tree/master/010-Java/030-Spring/60-Security/SpringSecurityWebExample

Demonstration

Access: http://localhost:8080/ItTechOfficeSpringSecurityWebExample/

It would redirect to http://localhost:8080/ItTechOfficeSpringSecurityWebExample/login

Image 016

After login, the browser would redirect to

http://localhost:8080/ItTechOfficeSpringSecurityWebExample/

Image 017

Access: http://localhost:8080/ItTechOfficeSpringSecurityWebExample/access

Image 018

 

The login Information could be obtain in SessionContext as below

Image 020Image 021

 

Set up process

Create a maven project

1. add the dependencies (pom.xml)

2. update the web.xml

3. create controller.

Image 025

Spring Security would use its login page for Form Login Mechanism. Spring security would monitor all url and check if the client has the specified authority.

Image 026

It configured the authentication manager.