2

I use Angular Cli, AngularFire2 and Firebase.

I use the angular hardware table that works like a charm with small volume data but when I switch to a number of 300,000 objects, my application is totally slowing down, or even bug ...

Voice my data:

{
    "rpps": [

        {
            "IdentifiantPP": "10101553021",
            "Prenom": "PAULINE",
            "Nom": "DEROT",
            "Libellesavoir": "-",
            "MSS": "-"
        },
        {
            "IdentifiantPP": "10101553039",
            "Prenom": "PAULINE",
            "Nom": "LEMOINE",
            "Libellesavoir": "-",
            "MSS": "-"
        },

...


    ]
}

Here is my code

//Service.ts

import { Injectable, Input } from '@angular/core';
import { Subject } from 'rxjs/Subject';
import * as firebase from 'firebase';
import DataSnapshot = firebase.database.DataSnapshot;
import { Observable, interval, pipe } from 'rxjs';
import {switchMap, map} from 'rxjs/operators';


import { AngularFireDatabase, AngularFireList, AngularFireObject} from 'angularfire2/database';

@Injectable()
export class AnnuairesService {

medecins: AngularFireList<any>;

constructor(private database: AngularFireDatabase) {this.medecins = database.list('rpps');  }

getMedecins() { return this.medecins.snapshotChanges().pipe(map(actions => {
  return actions.map(a => {
    const data = a.payload.val();
    const key = a.payload.key;
    return {key, ...data };
  });
})); }

}

Component.ts

export class MedListComponent   {

  Medecin = {
IdentifiantPP: '',
Prenom: '',
Nom: '',
Libellesavoir: '',
MSS: ''

   }

displayedColumns = [
'IdentifiantPP',
'Prenom',
'Nom',
'Libellesavoir',
'MSS'];

dataSource = new MatTableDataSource();

applyFilter(filterValue: string) {
    filterValue = filterValue.trim(); 
    filterValue = filterValue.toLowerCase(); 
    this.dataSource.filter = filterValue;
    }

@ViewChild(MatPaginator) paginator: MatPaginator;

ngAfterViewInit() {this.dataSource.paginator = this.paginator;}


ngOnInit(){ return this.annuairesService.getMedecins().subscribe(res => this.dataSource.data = res);}

constructor( private annuairesService: AnnuairesService, private router: Router, private database: AngularFireDatabase) {}

I think there must be solutions .. Is this problem recurring? I did not find topics on it.

enter image description here

7
  • Can you run the performance tool in chrome when you're loading? It should show you if the slow down is from scripting or rendering. Either way, you'll likely have to look at lazy loading or staggering the loading of the data from firebase.
    – jakhicks
    Commented Jun 28, 2018 at 15:59
  • @jakhicks I added the screenshot of lazy load. I think it's the "for each"..
    – Newbiiiie
    Commented Jun 29, 2018 at 6:45
  • I think your best bet is to reduce the number of items you're dealing with at a time. Does the api you have support pagination? You could request say, 50 at a time, or however many would be visible on screen at a time. When you scroll, request more.
    – jakhicks
    Commented Jun 29, 2018 at 8:31
  • Yes i have a pagination but i have search too... You think that it is possible ?
    – Newbiiiie
    Commented Jun 29, 2018 at 8:34
  • There are some libraries that on item destroying when they're out of view - github.com/angular-ui/ui-scroll . I don't have an example of an implementation for exactly what you're trying to do.It's possible for sure though!
    – jakhicks
    Commented Jun 29, 2018 at 8:35

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.